37 #ifndef MESH_PART_BUILDER_H    38 #define MESH_PART_BUILDER_H 1
    40 #include <boost/shared_ptr.hpp>    42 #include <Epetra_Comm.h>    44 #include<lifev/core/LifeV.hpp>    46 #include <lifev/core/array/GhostHandler.hpp>    47 #include <lifev/core/mesh/GraphCutterBase.hpp>    48 #include <lifev/core/mesh/GraphUtil.hpp>    67 template<
typename MeshType>
   116               const entityPID_Type& entityPIDList,
   117               const UInt partIndex);
   127         return M_globalToLocalElement;
   206 template<
typename MeshType>
   224 template<
typename MeshType>
   227                                      const entityPID_Type& entityPIDList,
   228                                      const UInt partIndex)
   233     const idList_Type& elementList = * (graph->at (partIndex) );
   238         gh.extendGraphFE ( graph,
   239                            entityPIDList.points,
   244     constructLocalMesh (elementList);
   256 template<
typename MeshType>
   258     const std::vector<Int>& elementList)
   260     std::map<Int, Int>::iterator  im;
   261     std::set<Int>::iterator       is;
   270     for (UInt jj = 0; jj < elementList.size(); ++jj)
   272         ielem = elementList[jj];
   273         M_localElements.push_back (ielem);
   276         for (UInt ii = 0; ii < M_elementVertices; ++ii)
   278             inode = M_originalMesh->element (ielem).point (ii).id();
   279             im    = M_globalToLocalVertex.find (inode);
   283             if (im == M_globalToLocalVertex.end() )
   285                 M_globalToLocalVertex.insert (std::make_pair (inode, count) );
   288                 M_localVertices.push_back (
   289                     M_originalMesh->element (ielem).point (ii).id() );
   294         for (UInt ii = 0; ii < M_elementRidges; ++ii)
   297             M_localRidges.insert (M_originalMesh->localRidgeId (ielem, ii) );
   301         for (UInt ii = 0; ii < M_elementFacets; ++ii)
   304             M_localFacets.insert (M_originalMesh->localFacetId (ielem, ii) );
   309 template<
typename MeshType>
   313     std::vector<Int>::iterator it;
   316     M_meshPart->pointList.reserve (M_localVertices.size() );
   318     M_meshPart->_bPoints.reserve (M_originalMesh->numBPoints()
   319                                   * M_localVertices.size()
   320                                   / M_originalMesh->numBPoints()
   323     typename MeshType::point_Type* pp = 0;
   327     for (it = M_localVertices.begin();
   328             it != M_localVertices.end(); ++it, ++inode)
   331         bool boundary = M_originalMesh->isBoundaryPoint (*it);
   334             ++M_nBoundaryVertices;
   337         pp = & (M_meshPart->addPoint (boundary, 
false) );
   338         *pp = M_originalMesh->point ( *it );
   340         pp->setLocalId ( inode );
   344 template<
typename MeshType>
   348     std::map<Int, Int>::iterator im;
   349     std::vector<Int>::iterator it;
   353     typename MeshType::element_Type* pv = 0;
   355     M_meshPart->elementList().reserve (M_localElements.size() );
   360     for (it = M_localElements.begin();
   361             it != M_localElements.end(); ++it, ++count)
   363         pv = & (M_meshPart->addElement() );
   364         *pv = M_originalMesh->element ( *it );
   365         pv->setLocalId ( count );
   367         M_globalToLocalElement.insert (std::make_pair (pv->id(),
   370         for (ID id = 0; id < M_elementVertices; ++id)
   372             inode = M_originalMesh->element (*it).point (id).id();
   376             im = M_globalToLocalVertex.find (inode);
   377             pv->setPoint (id, M_meshPart->point ( (*im).second ) );
   382 template<
typename MeshType>
   386     std::map<Int, Int>::iterator im;
   387     std::set<Int>::iterator is;
   389     typename MeshType::ridge_Type* pe;
   394     M_meshPart->ridgeList().reserve (M_localRidges.size() );
   397     for (is = M_localRidges.begin(); is != M_localRidges.end(); ++is, ++count)
   400         bool boundary = (M_originalMesh->isBoundaryRidge (*is) );
   407         pe = & (M_meshPart->addRidge (boundary) );
   408         *pe = M_originalMesh->ridge ( *is );
   410         pe->setLocalId (count);
   412         for (ID id = 0; id < 2; ++id)
   414             inode = M_originalMesh->ridge (*is).point (id).id();
   418             im = M_globalToLocalVertex.find (inode);
   419             pe->setPoint (id, M_meshPart->pointList ( (*im).second) );
   424 template<
typename MeshType>
   428     std::map<Int, Int>::iterator im;
   429     std::set<Int>::iterator      is;
   431     typename MeshType::facet_Type* pf = 0;
   437     M_meshPart->facetList().reserve (M_localFacets.size() );
   440     for (is = M_localFacets.begin(); is != M_localFacets.end(); ++is, ++count)
   443         bool boundary = (M_originalMesh->isBoundaryFacet (*is) );
   449         Int elem1 = M_originalMesh->facet (*is).firstAdjacentElementIdentity();
   450         Int elem2 = M_originalMesh->facet (*is).secondAdjacentElementIdentity();
   453         im =  M_globalToLocalElement.find (elem1);
   457         if (im == M_globalToLocalElement.end() )
   459             localElem1 = NotAnId;
   463             localElem1 = (*im).second;
   466         im =  M_globalToLocalElement.find (elem2);
   469         if (im == M_globalToLocalElement.end() )
   471             localElem2 = NotAnId;
   475             localElem2 = (*im).second;
   478         pf =  & (M_meshPart->addFacet (boundary) );
   479         *pf = M_originalMesh->facet ( *is );
   481         pf->setLocalId ( count );
   483         for (ID id = 0; id < M_originalMesh->facet (*is).S_numLocalVertices; ++id)
   485             inode = pf->point (id).id();
   486             im = M_globalToLocalVertex.find (inode);
   487             pf->setPoint (id, M_meshPart->pointList ( (*im).second) );
   491         ID ghostElem = ( localElem1 == NotAnId ) ? elem1 : elem2;
   493         if ( !boundary && ( localElem1 == NotAnId || localElem2 == NotAnId ) )
   496             pf->setFlag ( EntityFlags::SUBDOMAIN_INTERFACE );
   498             for ( UInt pointOnFacet = 0; pointOnFacet < MeshType::facet_Type::S_numLocalPoints; pointOnFacet++ )
   500                 M_meshPart->point ( pf->point ( pointOnFacet ).localId() ).setFlag ( EntityFlags::SUBDOMAIN_INTERFACE );
   504         ASSERT ( (localElem1 != NotAnId) || (localElem2 != NotAnId), 
"A hanging facet in mesh partitioner!");
   506         if ( localElem1 == NotAnId )
   508             pf->firstAdjacentElementIdentity()  = localElem2;
   509             pf->firstAdjacentElementPosition()  = M_originalMesh->facet (*is).secondAdjacentElementPosition();
   510             pf->secondAdjacentElementIdentity() = ghostElem;
   511             pf->secondAdjacentElementPosition() = NotAnId;
   514         else if ( localElem2 == NotAnId )
   516             pf->firstAdjacentElementIdentity()  = localElem1;
   517             pf->firstAdjacentElementPosition()  = M_originalMesh->facet (*is).firstAdjacentElementPosition();
   518             pf->secondAdjacentElementIdentity() = ghostElem;
   519             pf->secondAdjacentElementPosition() = NotAnId;
   523             pf->firstAdjacentElementIdentity()  = localElem1;
   524             pf->firstAdjacentElementPosition()  = M_originalMesh->facet (*is).firstAdjacentElementPosition();
   525             pf->secondAdjacentElementIdentity() = localElem2;
   526             pf->secondAdjacentElementPosition() = M_originalMesh->facet (*is).secondAdjacentElementPosition();
   530     M_meshPart->setLinkSwitch (
"HAS_ALL_FACETS");
   531     M_meshPart->setLinkSwitch (
"FACETS_HAVE_ADIACENCY");
   534 template<
typename MeshType>
   537     UInt nVolumes = M_localElements.size();
   538     UInt nNodes   = M_localVertices.size();
   539     UInt nEdges   = M_localRidges.size();
   540     UInt nFaces   = M_localFacets.size();
   542     M_meshPart->setMaxNumPoints (nNodes, 
true);
   543     M_meshPart->setMaxNumEdges  (nEdges, 
true);
   544     M_meshPart->setMaxNumFaces  (nFaces, 
true);
   545     M_meshPart->setMaxNumVolumes ( nVolumes, 
true);
   547     M_meshPart->setMaxNumGlobalPoints (M_originalMesh->numPoints() );
   548     M_meshPart->setNumGlobalVertices  (M_originalMesh->numVertices() );
   549     M_meshPart->setMaxNumGlobalRidges  (M_originalMesh->numRidges() );
   550     M_meshPart->setMaxNumGlobalFacets  (M_originalMesh->numFacets() );
   552     M_meshPart->setMaxNumGlobalElements (M_originalMesh->numElements() );
   553     M_meshPart->setNumBoundaryFacets    (M_nBoundaryFacets);
   555     M_meshPart->setNumBPoints   (M_nBoundaryVertices);
   556     M_meshPart->setNumBoundaryRidges    (M_nBoundaryRidges);
   558     M_meshPart->setNumVertices (nNodes );
   559     M_meshPart->setNumBVertices (M_nBoundaryVertices);
   561     if (MeshType::S_geoDimensions == 3)
   563         M_meshPart->updateElementRidges();
   566     M_meshPart->updateElementFacets();
   569 template<
typename MeshType>
   575     for ( UInt e = 0; e < M_meshPart->numElements(); e++ )
   577         typename MeshType::element_Type& element = M_meshPart->element (e);
   578         if (entityPID.elements[element.id()] != 
static_cast<Int>(M_partIndex) )
   580             element.setFlag ( EntityFlags::GHOST );
   584     for ( UInt f = 0; f < M_meshPart->numFacets(); f++ )
   586         typename MeshType::facet_Type& facet = M_meshPart->facet (f);
   587         if (entityPID.facets[facet.id()] != 
static_cast<Int>(M_partIndex) )
   589             facet.setFlag ( EntityFlags::GHOST );
   593     for ( UInt r = 0; r < M_meshPart->numRidges(); r++ )
   595         typename MeshType::ridge_Type& ridge = M_meshPart->ridge (r);
   596         if (entityPID.ridges[ridge.id()] != 
static_cast<Int>(M_partIndex) )
   598             ridge.setFlag ( EntityFlags::GHOST );
   602     for ( UInt p = 0; p < M_meshPart->numPoints(); ++p )
   604         typename MeshType::point_Type& point = M_meshPart->point (p);
   605         if (entityPID.points[point.id()] != 
static_cast<Int>(M_partIndex) )
   607             point.setFlag ( EntityFlags::GHOST );
   612 template<
typename MeshType>
   619     M_localVertices.resize (0);
   620     M_localRidges.clear();
   621     M_localFacets.clear();
   622     M_localElements.resize (0);
   623     M_globalToLocalVertex.clear();
   624     M_globalToLocalElement.clear();
 void constructRidges()
Construct edges. 
 
void constructNodes()
Construct nodes. 
 
std::shared_ptr< mesh_Type > meshPtr_Type
 
std::set< Int > M_localFacets
 
void run(const meshPtr_Type &meshPart, const idTablePtr_Type &graph, const entityPID_Type &entityPIDList, const UInt partIndex)
Run part builder. 
 
std::set< Int > M_localRidges
 
MeshPartBuilder(const meshPtr_Type &mesh, const UInt overlap, const commPtr_Type &comm)
Constructor. 
 
int32_type Int
Generic integer data. 
 
void updateInverseJacobian(const UInt &iQuadPt)
 
std::vector< Int > M_localVertices
 
void constructFacets()
Construct faces. 
 
void reset()
Resets the MeshPartBuilder object to the initial state. 
 
std::map< Int, Int > M_globalToLocalVertex
 
~MeshPartBuilder()
Empty destructor. 
 
std::map< Int, Int > M_globalToLocalElement
 
std::vector< LifeV::Int > idList_Type
 
std::shared_ptr< Epetra_Comm > commPtr_Type
 
void constructLocalMesh(const std::vector< Int > &elementList)
Private Methods. 
 
const std::map< Int, Int > & globalToLocalElement() const
 
meshPtr_Type M_originalMesh
 
Class that builds a mesh part, after the graph has been partitioned. 
 
std::vector< Int > M_localElements
 
std::shared_ptr< idTable_Type > idTablePtr_Type
 
void constructElements()
Construct volumes. 
 
void finalSetup()
Final setup of local mesh. 
 
void markEntityOwnership(const entityPID_Type &entityPID)
Mark entity ownership. 
 
void importFromHDF5(std::string const &fileName="ghostmap")
Import neighbor lists to an hdf5 file. 
 
uint32_type UInt
generic unsigned integer (used mainly for addressing) 
 
UInt M_nBoundaryVertices
Private Data Members.