52 #include <lifev/core/LifeV.hpp> 54 #include <lifev/core/array/ArraySimple.hpp> 55 #include <lifev/core/array/MapEpetraData.hpp> 57 #include <lifev/core/fem/DOFLocalPattern.hpp> 59 #include <lifev/core/mesh/ElementShapes.hpp> 61 #include <lifev/core/mesh/MeshEntity.hpp> 114 template <
typename MeshType>
128 template <
typename MeshType>
129 void update ( MeshType& );
135 template <
typename MeshType>
138 template <
typename MeshType>
152 return M_localToGlobalByBdFacet[facetId];
156 void showMe ( std::ostream& out = std::cout,
bool verbose =
false )
const;
157 void showMeByBdFacet (std::ostream& out = std::cout,
bool verbose =
false)
const;
197 return M_localToGlobal ( localNode, ElId );
239 typedef ID ( *facetToPointPtr_Type ) (
ID const& localFace,
ID const& point );
274 template <
typename MeshType>
284 for (
UInt i = 0; i < 5; ++i )
296 template <
typename MeshType>
300 typedef typename MeshType::elementShape_Type geoShape_Type;
301 typedef typename geoShape_Type::GeoBShape geoBShape_Type;
315 UInt nbGlobalElements = mesh.numGlobalElements();
316 UInt nbGlobalRidges = mesh.numGlobalRidges();
317 UInt nbGlobalPeaks = mesh.numGlobalPeaks();
318 UInt nbGlobalFacets = mesh.numGlobalFacets();
327 UInt nldof = nbLocalDofPerElement
333 ASSERT_PRE ( nldof == UInt ( M_elementDofPattern.nbLocalDof() ),
"Something wrong in FE specification" ) ;
336 M_totalDof = nbGlobalElements * nbLocalDofPerElement
337 + nbGlobalRidges * nbLocalDofPerRidge
338 + nbGlobalPeaks * nbLocalDofPerPeak
339 + nbGlobalFacets * nbLocalDofPerFacet;
342 M_localToGlobal.reshape ( nldof, M_numElement );
345 bool update_ridges ( nbLocalDofPerRidge != 0 && ! mesh.hasLocalRidges() && (MeshType::S_geoDimensions == 3) );
348 mesh.updateElementRidges();
351 bool update_facets ( nbLocalDofPerFacet != 0 && ! mesh.hasLocalFacets() );
354 mesh.updateElementFacets();
363 if ( nbLocalDofPerPeak > 0 )
369 ID pID = mesh.element ( ie ).point ( i ).id();
370 for ( l = 0; l < nbLocalDofPerPeak; ++l )
373 UInt dof = gcount + pID * nbLocalDofPerPeak + l;
374 ASSERT ( dof != NotAnId,
"the dof is not properly set" );
375 M_localToGlobal ( lc++, ie ) = dof;
381 gcount += nbLocalDofPerPeak * nbGlobalPeaks;
385 if ( nbLocalDofPerRidge > 0 )
391 UInt rID = mesh.ridge (mesh.localRidgeId (ie, i) ).id();
392 for ( l = 0; l < nbLocalDofPerRidge; ++l )
394 UInt dof = gcount + rID * nbLocalDofPerRidge + l;
395 ASSERT ( dof != NotAnId,
"the dof is not properly set" );
396 M_localToGlobal ( lc++, ie ) = dof;
402 gcount += nbGlobalRidges * nbLocalDofPerRidge;
406 if ( nbLocalDofPerFacet > 0 )
413 UInt fID = mesh.facet ( mesh.localFacetId ( ie, i ) ).id();
414 for ( l = 0; l < nbLocalDofPerFacet; ++l )
416 UInt dof = gcount + fID * nbLocalDofPerFacet + l;
417 ASSERT ( dof != NotAnId,
"the dof is not properly set" );
418 M_localToGlobal ( lc++, ie ) = dof;
424 gcount += nbGlobalFacets * nbLocalDofPerFacet;
428 if ( nbLocalDofPerElement > 0 )
432 ID eID = mesh.element ( ie ).id();
433 for ( l = 0; l < nbLocalDofPerElement; ++l )
435 UInt dof = gcount + eID * nbLocalDofPerElement + l;
436 ASSERT ( dof != NotAnId,
"the dof is not properly set" );
437 M_localToGlobal ( lc++, ie ) = dof;
440 gcount += nbGlobalElements * nbLocalDofPerElement;
443 ASSERT_POS ( gcount == M_totalDof ,
"Something wrong in Dof Setup " << gcount <<
" " << M_totalDof ) ;
446 UInt nBElemRidges = geoBShape_Type::S_numRidges;
447 UInt nBElemFacets = geoBShape_Type::S_numFacets;
449 std::vector<ID> globalDOFOnBdFacet (nbLocalDofPerPeak * nBElemRidges + nBElemFacets * nbLocalDofPerRidge + nbLocalDofPerFacet);
450 M_localToGlobalByBdFacet.resize (mesh.numBoundaryFacets() );
452 for (
ID iBoundaryFacet = 0 ; iBoundaryFacet < mesh.numBoundaryFacets(); ++iBoundaryFacet )
454 ID iAdjacentElem = mesh.boundaryFacet ( iBoundaryFacet ).firstAdjacentElementIdentity();
455 ID iElemBFacet = mesh.boundaryFacet ( iBoundaryFacet ).firstAdjacentElementPosition();
457 UInt lDof (0), dofOffset;
460 if (nbLocalDofPerPeak)
461 for (
ID iBElemRidge = 0; iBElemRidge < nBElemRidges; ++iBElemRidge )
463 ID iElemPeak = geoShape_Type::facetToPeak ( iElemBFacet, iBElemRidge );
464 dofOffset = iElemPeak * nbLocalDofPerPeak;
465 for (
ID l = 0; l < nbLocalDofPerPeak; ++l )
467 globalDOFOnBdFacet[ lDof++ ] = M_localToGlobal ( dofOffset + l, iAdjacentElem );
472 if (nbLocalDofPerRidge)
473 for (
ID iBElemFacets = 0; iBElemFacets < nBElemFacets; ++iBElemFacets )
475 ID iElemRidge = geoShape_Type::facetToRidge ( iElemBFacet, iBElemFacets );
476 dofOffset = nbDofElemPeaks + iElemRidge * nbLocalDofPerRidge;
477 for (
ID l = 0; l < nbLocalDofPerRidge; ++l )
479 globalDOFOnBdFacet[ lDof++ ] = M_localToGlobal ( dofOffset + l, iAdjacentElem );
484 dofOffset = nbDofElemPeaks + nbDofElemRidges + iElemBFacet * nbLocalDofPerFacet;
485 for (
ID l = 0; l < nbLocalDofPerFacet; ++l )
487 globalDOFOnBdFacet[ lDof++ ] = M_localToGlobal ( dofOffset + l, iAdjacentElem );
491 M_localToGlobalByBdFacet[iBoundaryFacet] = globalDOFOnBdFacet;
497 mesh.cleanElementRidges();
501 mesh.cleanElementFacets();
505 template <
typename MeshType>
523 std::set<Int> myGlobalElementsSet;
526 const UInt pointOffset ( 0 );
531 for (
UInt i = 0; i < mesh.numElements(); i++ )
533 const typename MeshType::element_Type& element = mesh.element ( i );
536 for (
UInt k = 0; k < element.S_numPoints; k++ )
538 const typename MeshType::point_Type point = element.point ( k );
539 if ( point.isOwned() )
543 myGlobalElementsSet.insert ( pointOffset + point.id() + d * mesh.numGlobalPoints() );
549 for (
UInt k = 0; k < element.S_numRidges; k++ )
551 const typename MeshType::ridge_Type ridge = mesh.ridge ( mesh.localRidgeId ( i, k ) );
552 if ( ridge.isOwned() )
556 myGlobalElementsSet.insert ( ridgeOffset + ridge.id() + d * mesh.numGlobalRidges() );
562 for (
UInt k = 0; k < element.S_numFacets; k++ )
564 const typename MeshType::facet_Type facet = mesh.facet ( mesh.localFacetId ( i, k ) );
565 if ( facet.isOwned() )
569 myGlobalElementsSet.insert ( facetOffset + facet.id() + d * mesh.numGlobalFacets() );
575 if ( element.isOwned() )
579 myGlobalElementsSet.insert ( elementOffset + element.id() + d * mesh.numGlobalFacets() );
584 std::vector<Int> myGlobalElements ( myGlobalElementsSet.size() );
585 std::copy ( myGlobalElementsSet.begin(), myGlobalElementsSet.end(), myGlobalElements.begin() );
587 return myGlobalElements;
590 template <
typename MeshType>
593 std::set<Int> mapDataSetUnique;
594 std::set<Int> mapDataSetRepeated;
597 const UInt pointOffset = 0;
602 for (
UInt i = 0; i < mesh.numElements(); i++ )
604 const typename MeshType::element_Type& element = mesh.element ( i );
607 for (
UInt k = 0; k < element.S_numPoints; k++ )
609 const typename MeshType::point_Type point = element.point ( k );
612 if ( point.isOwned() )
614 mapDataSetUnique.insert ( pointOffset + point.id() + d * mesh.numGlobalPoints() );
616 mapDataSetRepeated.insert ( pointOffset + point.id() + d * mesh.numGlobalPoints() );
621 for (
UInt k = 0; k < element.S_numRidges; k++ )
623 const typename MeshType::ridge_Type ridge = mesh.ridge ( mesh.localRidgeId ( i, k ) );
626 if ( ridge.isOwned() )
628 mapDataSetUnique.insert ( ridgeOffset + ridge.id() + d * mesh.numGlobalRidges() );
630 mapDataSetRepeated.insert ( ridgeOffset + ridge.id() + d * mesh.numGlobalRidges() );
635 for (
UInt k = 0; k < element.S_numFacets; k++ )
637 const typename MeshType::facet_Type facet = mesh.facet ( mesh.localFacetId ( i, k ) );
640 if ( facet.isOwned() )
642 mapDataSetUnique.insert ( facetOffset + facet.id() + d * mesh.numGlobalFacets() );
644 mapDataSetRepeated.insert ( facetOffset + facet.id() + d * mesh.numGlobalFacets() );
651 if ( element.isOwned() )
653 mapDataSetUnique.insert ( elementOffset + element.id() + d * mesh.numGlobalFacets() );
655 mapDataSetRepeated.insert ( elementOffset + element.id() + d * mesh.numGlobalFacets() );
660 mapData.unique.assign ( mapDataSetUnique.begin(), mapDataSetUnique.end() );
661 mapData.repeated.assign ( mapDataSetRepeated.begin(), mapDataSetRepeated.end() );
const UInt & numLocalVertices() const
Number of local vertices (in a elment)
MapEpetraData createMapData(MeshType &mesh)
std::vector< std::vector< ID > > M_localToGlobalByBdFacet
UInt nbDofPerFacet() const
Return the number of degrees of freedom located on the facet. (face in 3D)
DOF(const DOFLocalPattern &fePattern)
void update(MeshType &)
Build the localToGlobal table.
const UInt & numLocalEdges() const
Number of local edges (in a elment)
Container_Type M_localToGlobal
const DOFLocalPattern & M_elementDofPattern
The pattern of the local degrees of freedom.
const UInt & nbDofPerElement() const
Return the number of degrees of freedom located on the element. (volume in 3D)
void updateInverseJacobian(const UInt &iQuadPt)
const UInt & numElements() const
Number of elements in mesh.
DOF(const DOF &dof2)
Copy constructor.
const UInt & numLocalDof() const
The number of local DOF (nodes) in the finite element.
vectorSize_Type const numberOfColumns() const
Return the number of columns.
const ID & localToGlobalMap(const ID ElId, const ID localNode) const
Return the specified entries of the localToGlobal table.
const UInt & numTotalDof() const
The total number of Dof.
void setTotalDof(const UInt &totalDof)
std::vector< ID > localToGlobalMapOnBdFacet(const ID &facetId) const
DOFLocalPattern - A class to store the "couplings" between the basis functions.
ArraySimple< UInt > Container_Type
UInt nbDofPerPeak() const
Return the number of degrees of freedom located on the peak (vertex in 3D).
void showMe(std::ostream &out=std::cout, bool verbose=false) const
Ouput.
ID localToGlobalMapByBdFacet(const ID &facetId, const ID &localDof) const
UInt M_dofPositionByEntity[5]
std::vector< Int > globalElements(MeshType &mesh)
Build the globalElements list.
const DOFLocalPattern & localDofPattern() const
Getter for the localDofPattern.
facetToPointPtr_Type M_facetToPoint
const UInt & nbLocalDof() const
Return the number of local degrees of freedom.
DOF(MeshType &mesh, const DOFLocalPattern &fePattern)
Constructor accepting a mesh as parameter.
void showMeByBdFacet(std::ostream &out=std::cout, bool verbose=false) const
const UInt & numLocalFaces() const
Number of local faces (in a elment)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
UInt nbDofPerRidge() const
Return the number of degrees of freedom located on the ridge. (edge in 3D)