37template <
class T,
unsigned Dim,
class MeshType >
44template <
class T,
unsigned Dim,
class MeshType >
49 for (
unsigned d=0; d <
Dim; ++d) {
62 WeOwnFieldLayout =
true;
67template <
class T,
unsigned Dim,
class MeshType >
72 for (
unsigned d=0; d <
Dim; ++d) {
83 store_mesh(
new MeshType(*(r.
theMesh)),
true);
98template <
class T,
unsigned Dim,
class MeshType >
116template <
class T,
unsigned Dim,
class MeshType >
118 MeshType& mesh,
int vnodes) {
125 store_mesh(&mesh,
false);
126 changeDomain(domain, vnodes);
131template <
class T,
unsigned Dim,
class MeshType >
133 MeshType& mesh,
int vnodes) {
138 "Number of PRegion arguments does not match RegionLayout dimension!!");
142 store_mesh(&mesh,
false);
145 changeDomain(dom, vnodes);
150template <
class T,
unsigned Dim,
class MeshType >
158 "Number of PRegion arguments does not match RegionLayout dimension!!");
162 store_mesh(&mesh,
false);
166 changeDomain(dom, vnodes);
171template <
class T,
unsigned Dim,
class MeshType >
179 "Number of PRegion arguments does not match RegionLayout dimension!!");
183 store_mesh(&mesh,
false);
188 changeDomain(dom, vnodes);
195template <
class T,
unsigned Dim,
class MeshType >
203 for (
unsigned int i=0; i<
Dim; i++)
204 extended[i] =
Index(domain[i].first(), domain[i].last()+1,
209 store_mesh(
new MeshType(extended),
true);
210 changeDomain(domain, vnodes);
215template <
class T,
unsigned Dim,
class MeshType >
221 "Number of Index arguments does not match RegionLayout dimension!!");
227 store_mesh(
new MeshType(extended),
true);
230 changeDomain(dom, vnodes);
235template <
class T,
unsigned Dim,
class MeshType >
242 "Number of Index arguments does not match RegionLayout dimension!!");
249 store_mesh(
new MeshType(ex1, ex2),
true);
253 changeDomain(dom, vnodes);
258template <
class T,
unsigned Dim,
class MeshType >
260 const Index& i3,
int vnodes) {
263 "Number of Index arguments does not match RegionLayout dimension!!");
271 store_mesh(
new MeshType(ex1, ex2, ex3),
true);
276 changeDomain(dom, vnodes);
283template <
class T,
unsigned Dim,
class MeshType >
293 store_mesh(&mesh,
false);
294 changeDomain(domain, vnodes);
299template <
class T,
unsigned Dim,
class MeshType >
307 "Number of Index arguments does not match RegionLayout dimension!!");
311 store_mesh(&mesh,
false);
314 changeDomain(dom, vnodes);
319template <
class T,
unsigned Dim,
class MeshType >
326 "Number of Index arguments does not match RegionLayout dimension!!");
330 store_mesh(&mesh,
false);
334 changeDomain(dom, vnodes);
339template <
class T,
unsigned Dim,
class MeshType >
347 "Number of Index arguments does not match RegionLayout dimension!!");
351 store_mesh(&mesh,
false);
356 changeDomain(dom, vnodes);
362template <
class T,
unsigned Dim,
class MeshType >
370 for (
unsigned int i=0; i<
Dim; i++)
371 extended[i] =
Index(domain[i].first(), domain[i].last()+1,
376 store_mesh(
new MeshType(extended),
true);
383template <
class T,
unsigned Dim,
class MeshType >
392 store_mesh(&mesh,
false);
400template <
class T,
unsigned Dim,
class MeshType >
414 for (d=0; d <
Dim; ++d)
415 ex[d] =
Index(domain[d].first(),domain[d].last()+1,domain[d].stride());
416 store_mesh(
new MeshType(ex),
true);
420 for (d=0; d <
Dim; ++d) {
421 IndexOffset[d] = domain[d].first();
422 CenterOffset[d] = (MeshVertices[d].length() > domain[d].length());
432 Domain = convert_index(FLayout->getDomain());
435 make_rnodes(Domain, *FLayout);
443template <
class T,
unsigned Dim,
class MeshType >
460 for (d=0; d <
Dim; ++d) {
462 CenterOffset[d] =
true;
477 make_rnodes(Domain, *FLayout);
485template <
class T,
unsigned Dim,
class MeshType >
499 for (d=0; d <
Dim; ++d)
500 ex[d] =
Index(domain[d].first(),domain[d].last()+1,domain[d].stride());
501 store_mesh(
new MeshType(ex),
true);
505 for (d=0; d <
Dim; ++d) {
506 IndexOffset[d] = fl.
getDomain()[d].first();
507 CenterOffset[d] = (theMesh->gridSizes[d] > fl.
getDomain()[d].length());
512 store_flayout(&fl,
false);
513 make_rnodes(Domain, *FLayout);
524template <
class T,
unsigned Dim,
class MeshType >
534 for (d=0; d<
Dim; d++) {
535 int first = ni[d].first() - IndexOffset[d];
536 int last = ni[d].last() - IndexOffset[d] + CenterOffset[d];
537 FirstPoint[d] =
Index(first, first);
538 LastPoint[d] =
Index(last, last);
542 Vektor<T,Dim> FirstCoord = theMesh->getVertexPosition(FirstPoint);
543 Vektor<T,Dim> LastCoord = theMesh->getVertexPosition(LastPoint);
544 for (d=0; d<
Dim; d++) {
545 if (!CenterOffset[d]) {
546 if ( !(FirstPoint[d] ==
Index(0,0)) ) {
547 FirstPoint[d] = FirstPoint[d] - 1;
548 FirstCoord = theMesh->getVertexPosition(FirstPoint);
549 FirstCoord(d) = FirstCoord(d) +
550 0.5 * theMesh->getDeltaVertex(FirstPoint)(d);
552 int final = theMesh->gridSizes[d]-1;
553 if ( !(LastPoint[d] ==
Index(
final,
final)) )
554 LastCoord(d) = LastCoord(d) +
555 0.5 * theMesh->getDeltaVertex(LastPoint)(d);
558 new_pregion[d] =
PRegion<T>(FirstCoord(d), LastCoord(d));
570template <
class T,
unsigned Dim,
class MeshType >
581 for (d=0; d<
Dim; d++) {
582 FirstCoord(d) =
nr[d].first();
583 LastCoord(d) =
nr[d].last();
585 NDIndex<Dim> FirstPoint = theMesh->getNearestVertex(FirstCoord);
586 NDIndex<Dim> LastPoint = theMesh->getNearestVertex(LastCoord);
587 for (d=0; d<
Dim; d++) {
588 if (!CenterOffset[d]) {
589 if (theMesh->getVertexPosition(FirstPoint)(d) < FirstCoord(d))
590 FirstPoint[d] = FirstPoint[d] + 1;
591 if (theMesh->getVertexPosition(LastPoint)(d) > LastCoord(d))
592 LastPoint[d] = LastPoint[d] - 1;
594 index[d] =
Index(FirstPoint[d].first() + IndexOffset[d],
595 LastPoint[d].first() + IndexOffset[d] - CenterOffset[d]);
605template <
class T,
unsigned Dim,
class MeshType >
623 for ( ; lociter != endloc; ++lociter) {
625 StaticRnodePool.create_rnode(
626 convert_index((*((*lociter).second)).getDomain()),
627 (*((*lociter).second)).getNode());
640 for ( ; remiter != endrem; ++remiter) {
642 StaticRnodePool.create_rnode(
643 convert_index((*((*remiter).second)).getDomain()),
644 (*((*remiter).second)).getNode());
649 Remote_ac->insert( rrnode_t(rnode->
getDomain(), rnode) );
667template <
class T,
unsigned Dim,
class MeshType >
675 for ( ; lociter != endloc; ++lociter)
676 StaticRnodePool.push_back((*lociter).second);
677 Local_ac.erase(Local_ac.begin(), Local_ac.end());
680 if (Remote_ac != 0) {
683 for ( ; remiter != endrem; ++remiter)
684 StaticRnodePool.push_back((*remiter).second);
693template <
class T,
unsigned Dim,
class MeshType >
705 WeOwnFieldLayout = WeOwn;
714template <
class T,
unsigned Dim,
class MeshType >
718 FLayout->checkout(*
this);
719 if (WeOwnFieldLayout)
728template <
class T,
unsigned Dim,
class MeshType >
741 theMesh->checkin(*
this);
742 for (
unsigned int d=0; d <
Dim; ++d)
743 MeshVertices[d] =
Index(theMesh->gridSizes[d]);
751template <
class T,
unsigned Dim,
class MeshType >
756 theMesh->checkout(*
this);
766template <
class T,
unsigned Dim,
class MeshType >
773 typename MeshType::MeshVektor_t morigin = m->get_origin();
776 for (d=0; d <
Dim; ++d)
777 meshCells[d] =
Index(MeshVertices[d].first(),MeshVertices[d].last()-1);
778 typename MeshType::MeshVektor_t msize = m->getDeltaVertex(meshCells);
779 for (d=0; d <
Dim; ++d)
780 retDomain[d] =
PRegion<T>(morigin[d], morigin[d] + msize[d]);
787template <
class T,
unsigned Dim,
class MeshType >
794 for (
unsigned int d=0; d <
Dim; ++d)
795 mvertices[d] =
Index(m->gridSizes[d]);
802template <
class T,
unsigned Dim,
class MeshType >
810 out <<
"Total Domain = " << f.
getDomain() <<
"\n";
813 out <<
"Local Rnodes = " << f.
size_iv() <<
"\n";
816 for(icount=0 ; v_i != v_e; ++v_i, ++icount)
817 out <<
" rnode " << icount <<
" : " << (*v_i).second->getDomain() <<
"\n";
820 out <<
"Remote Rnodes = " << f.
size_rdv() <<
"\n";
824 for (icount=0 ; dv_i != dv_e; ++dv_i, ++icount)
825 out <<
" rnode " << icount <<
" : " << (*dv_i).first <<
"\n";
845template <
class T,
unsigned Dim,
class MeshType >
856 FLayout->Repartition(ni, nf);
864template <
class T,
unsigned Dim,
class MeshType >
869 if (theMesh != 0 && userlist->
getUserListID() == theMesh->get_Id()) {
878 if (!(mvertices == MeshVertices)) {
881 MeshVertices = mvertices;
882 if (WeOwnFieldLayout)
883 changeDomain(getMeshDomain(theMesh), size_iv() + size_rdv());
885 changeDomain(*FLayout);
889 Domain = getMeshDomain(theMesh);
890 make_rnodes(Domain, *FLayout);
903 make_rnodes(Domain, *newLayout);
911template <
class T,
unsigned Dim,
class MeshType >
916 if (FLayout != 0 && FLayout->get_Id() == userlist->
getUserListID()) {
923 }
else if (theMesh != 0 && userlist->
getUserListID() == theMesh->get_Id()) {
933 WARNMSG(
"RegionLayout: notified of unknown UserList being deleted.");
std::ostream & operator<<(std::ostream &out, const RegionLayout< T, Dim, MeshType > &f)
iterator_dv begin_rdv(const GuardCellSizes< Dim > &gc=gc0())
iterator_dv end_rdv(const GuardCellSizes< Dim > &gc=gc0())
const NDIndex< Dim > & getDomain() const
void checkin(FieldLayoutUser &f, const GuardCellSizes< Dim > &gc=gc0())
ac_id_vnodes::iterator iterator_iv
virtual void Repartition(UserList *)=0
void changeDomain(FieldLayout< Dim > &)
void RepartitionLayout(NDIndex< Dim > *, NDIndex< Dim > *)
void make_rnodes(const NDRegion< T, Dim > &, FieldLayout< Dim > &)
NDRegion< T, Dim > getMeshDomain(MeshType *)
NDIndex< Dim > convert_region(const NDRegion< T, Dim > &) const
NDRegion< T, Dim > convert_index(const NDIndex< Dim > &) const
ac_id_vnodes::size_type size_iv() const
NDRegion< T, Dim > Domain
virtual void notifyUserOfDelete(UserList *)
ac_id_vnodes::const_iterator const_iterator_iv
ac_domain_vnodes::size_type size_rdv() const
virtual void Repartition(UserList *)
FieldLayout< Dim > * FLayout
const NDRegion< T, Dim > & getDomain() const
NDIndex< Dim > getMeshVertices(MeshType *)
FieldLayout< Dim > & getFieldLayout()
void store_flayout(FieldLayout< Dim > *, bool WeOwn)
void store_mesh(MeshType *, bool WeOwn)
const NDRegion< T, Dim > & getDomain()
ID_t getUserListID() const
UserList_t::iterator iterator_user
rep_type::iterator iterator
std::pair< Unique::type, Rnode< T, Dim > * > value_type