37 template <
class T,
unsigned Dim,
class MeshType >
44 template <
class T,
unsigned Dim,
class MeshType >
49 for (
unsigned d=0; d <
Dim; ++d) {
62 WeOwnFieldLayout =
true;
67 template <
class T,
unsigned Dim,
class MeshType >
72 for (
unsigned d=0; d <
Dim; ++d) {
83 store_mesh(
new MeshType(*(r.
theMesh)),
true);
98 template <
class T,
unsigned Dim,
class MeshType >
116 template <
class T,
unsigned Dim,
class MeshType >
118 MeshType& mesh,
int vnodes) {
125 store_mesh(&mesh,
false);
126 changeDomain(domain, vnodes);
131 template <
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);
150 template <
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);
171 template <
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);
195 template <
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);
215 template <
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);
235 template <
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);
258 template <
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);
283 template <
class T,
unsigned Dim,
class MeshType >
293 store_mesh(&mesh,
false);
294 changeDomain(domain, vnodes);
299 template <
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);
319 template <
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);
339 template <
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);
362 template <
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);
383 template <
class T,
unsigned Dim,
class MeshType >
392 store_mesh(&mesh,
false);
400 template <
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);
443 template <
class T,
unsigned Dim,
class MeshType >
460 for (d=0; d <
Dim; ++d) {
462 CenterOffset[d] =
true;
477 make_rnodes(Domain, *FLayout);
485 template <
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);
524 template <
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));
570 template <
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]);
601 #ifdef IPPL_USE_MEMBER_TEMPLATES
611 template <
class T,
unsigned Dim,
class MeshType >
629 for ( ; lociter != endloc; ++lociter) {
631 StaticRnodePool.create_rnode(
632 convert_index((*((*lociter).second)).getDomain()),
633 (*((*lociter).second)).getNode());
646 for ( ; remiter != endrem; ++remiter) {
648 StaticRnodePool.create_rnode(
649 convert_index((*((*remiter).second)).getDomain()),
650 (*((*remiter).second)).getNode());
655 Remote_ac->insert( rrnode_t(rnode->
getDomain(), rnode) );
673 template <
class T,
unsigned Dim,
class MeshType >
681 for ( ; lociter != endloc; ++lociter)
682 StaticRnodePool.push_back((*lociter).second);
683 Local_ac.erase(Local_ac.begin(), Local_ac.end());
686 if (Remote_ac != 0) {
689 for ( ; remiter != endrem; ++remiter)
690 StaticRnodePool.push_back((*remiter).second);
699 template <
class T,
unsigned Dim,
class MeshType >
711 WeOwnFieldLayout = WeOwn;
720 template <
class T,
unsigned Dim,
class MeshType >
724 FLayout->checkout(*
this);
725 if (WeOwnFieldLayout)
734 template <
class T,
unsigned Dim,
class MeshType >
747 theMesh->checkin(*
this);
748 for (
unsigned int d=0; d <
Dim; ++d)
749 MeshVertices[d] =
Index(theMesh->gridSizes[d]);
757 template <
class T,
unsigned Dim,
class MeshType >
762 theMesh->checkout(*
this);
772 template <
class T,
unsigned Dim,
class MeshType >
779 typename MeshType::MeshVektor_t morigin = m->get_origin();
782 for (d=0; d <
Dim; ++d)
783 meshCells[d] =
Index(MeshVertices[d].first(),MeshVertices[d].last()-1);
784 typename MeshType::MeshVektor_t msize = m->getDeltaVertex(meshCells);
785 for (d=0; d <
Dim; ++d)
786 retDomain[d] =
PRegion<T>(morigin[d], morigin[d] + msize[d]);
793 template <
class T,
unsigned Dim,
class MeshType >
800 for (
unsigned int d=0; d <
Dim; ++d)
801 mvertices[d] =
Index(m->gridSizes[d]);
808 template <
class T,
unsigned Dim,
class MeshType >
809 std::ostream& operator<<(std::ostream& out, const RegionLayout<T,Dim,MeshType>& f) {
816 out <<
"Total Domain = " << f.getDomain() <<
"\n";
819 out <<
"Local Rnodes = " << f.size_iv() <<
"\n";
822 for(icount=0 ; v_i != v_e; ++v_i, ++icount)
823 out <<
" rnode " << icount <<
" : " << (*v_i).second->getDomain() <<
"\n";
826 out <<
"Remote Rnodes = " << f.size_rdv() <<
"\n";
827 if (f.size_rdv() > 0) {
830 for (icount=0 ; dv_i != dv_e; ++dv_i, ++icount)
831 out <<
" rnode " << icount <<
" : " << (*dv_i).first <<
"\n";
835 out <<
"Internal FieldLayout = " << f.getFieldLayout();
851 template <
class T,
unsigned Dim,
class MeshType >
862 FLayout->Repartition(ni, nf);
870 template <
class T,
unsigned Dim,
class MeshType >
875 if (theMesh != 0 && userlist->
getUserListID() == theMesh->get_Id()) {
884 if (!(mvertices == MeshVertices)) {
887 MeshVertices = mvertices;
888 if (WeOwnFieldLayout)
889 changeDomain(getMeshDomain(theMesh), size_iv() + size_rdv());
891 changeDomain(*FLayout);
895 Domain = getMeshDomain(theMesh);
896 make_rnodes(Domain, *FLayout);
909 make_rnodes(Domain, *newLayout);
917 template <
class T,
unsigned Dim,
class MeshType >
922 if (FLayout != 0 && FLayout->get_Id() == userlist->
getUserListID()) {
929 }
else if (theMesh != 0 && userlist->
getUserListID() == theMesh->get_Id()) {
939 WARNMSG(
"RegionLayout: notified of unknown UserList being deleted.");
const NDRegion< T, Dim > & getDomain()
void changeDomain(FieldLayout< Dim > &)
FieldLayout< Dim > * FLayout
void store_mesh(MeshType *, bool WeOwn)
void make_rnodes(const NDRegion< T, Dim > &, FieldLayout< Dim > &)
virtual void Repartition(UserList *)
ID_t getUserListID() const
NDIndex< Dim > getMeshVertices(MeshType *)
ac_id_vnodes::size_type size_iv() const
iterator_dv end_rdv(const GuardCellSizes< Dim > &gc=gc0())
ac_domain_vnodes::size_type size_rdv() const
ac_id_vnodes::iterator iterator_iv
NDRegion< T, Dim > convert_index(const NDIndex< Dim > &) const
virtual void Repartition(UserList *)=0
NDRegion< T, Dim > getMeshDomain(MeshType *)
std::pair< Unique::type, Rnode< T, Dim > * > value_type
virtual void notifyUserOfDelete(UserList *)
UserList_t::iterator iterator_user
ac_id_vnodes::const_iterator const_iterator_iv
NDRegion< T, Dim > Domain
void RepartitionLayout(NDIndex< Dim > *, NDIndex< Dim > *)
iterator_dv begin_rdv(const GuardCellSizes< Dim > &gc=gc0())
NDIndex< Dim > convert_region(const NDRegion< T, Dim > &) const
rep_type::iterator iterator
const NDIndex< Dim > & getDomain() const
void checkin(FieldLayoutUser &f, const GuardCellSizes< Dim > &gc=gc0())
void store_flayout(FieldLayout< Dim > *, bool WeOwn)