42 #ifndef _DOFINTERFACE3DTO3D_HH 43 #define _DOFINTERFACE3DTO3D_HH 45 #include <lifev/core/LifeV.hpp> 47 #include <lifev/core/mesh/MarkerDefinitions.hpp> 49 #include <lifev/core/fem/DOFInterface.hpp> 50 #include <lifev/core/fem/ReferenceFE.hpp> 51 #include <lifev/core/fem/DOF.hpp> 52 #include <lifev/core/fem/CurrentFEManifold.hpp> 53 #include <lifev/core/util/LifeChrono.hpp> 55 #include <lifev/core/array/MatrixSmall.hpp> 72 class DOFInterface3Dto3D:
78 typedef boost::numeric::ublas::vector<Real> Vector;
79 typedef std::function<
bool (
const std::vector<Real>&,
const std::vector<Real>&,
const Real& ) > fct;
100 DOFInterface3Dto3D (
const ReferenceFE& refFE,
const DOF& dof1,
const DOF& dof2 );
109 DOFInterface3Dto3D (
const ReferenceFE& refFE1,
const DOF& dof1,
const ReferenceFE& refFE2,
const DOF& dof2 );
115 DOFInterface3Dto3D (
const ReferenceFE& refFE,
const DOF& dof);
125 void setup (
const ReferenceFE& refFE,
const DOF& dof1,
const DOF& dof2 );
141 template <
typename MeshType>
142 void update ( MeshType& mesh1,
147 Int const*
const flag3 = 0 );
158 template <
typename MeshType>
159 void update ( MeshType& mesh,
162 const Real& tol,
const fct& coupled );
175 template <
typename MeshType>
176 void interpolate ( MeshType& mesh2,
const UInt nbComp,
const Vector& v, Vector& vI );
185 const UInt& numTotalDof()
const 187 return M_dof->numTotalDof();
191 const std::list< std::pair<ID, ID> >& connectedFacetMap()
const 193 return M_facetToFacetConnectionList;
201 typedef std::list< std::pair<ID, ID> >::iterator Iterator;
217 template <
typename MeshType>
218 void updateFacetConnections (
const MeshType& mesh1,
const markerID_Type& flag1,
219 const MeshType& mesh2,
const markerID_Type& flag2,
const Real& tol,
const fct& coupled );
232 template <
typename MeshType>
233 void updateDofConnections (
const MeshType& mesh1,
const DOF& dof1,
234 const MeshType& mesh2,
const DOF& dof2,
const Real& tol,
const fct& coupled,
235 Int const*
const flag3 = 0 );
254 std::shared_ptr<DOF> M_dof;
257 std::list< std::pair<ID, ID> > M_facetToFacetConnectionList;
261 std::list< std::pair<ID, ID> > M_dofToDofConnectionList;
270 bool coincide (
const std::vector<Real>& p1,
const std::vector<Real>& p2,
const Real& tol );
276 template <
typename MeshType>
277 void DOFInterface3Dto3D::update ( MeshType& mesh1,
const markerID_Type& flag1,
279 const Real& tol,
Int const*
const flag3 )
283 updateFacetConnections ( mesh1, flag1, mesh2, flag2, tol, coincide );
285 if ( M_refFE1->nbDof() > M_refFE2->nbDof() )
288 M_dof->update ( mesh2 );
289 updateDofConnections ( mesh1, *M_dof1, mesh2, *M_dof, tol, coincide, flag3 );
294 updateDofConnections ( mesh1, *M_dof1, mesh2, *M_dof2, tol, coincide, flag3 );
299 template <
typename MeshType>
300 void DOFInterface3Dto3D::update ( MeshType& mesh,
const markerID_Type& flag1,
304 updateFacetConnections ( mesh, flag1, mesh, flag2, tol, coupled );
307 updateDofConnections ( mesh, *M_dof1, mesh, *M_dof2, tol, coupled );
311 template <
typename MeshType>
312 void DOFInterface3Dto3D::interpolate ( MeshType& mesh2,
const UInt nbComp,
const Vector& v, Vector& vI )
315 typedef typename MeshType::elementShape_Type GeoShape;
316 typedef typename GeoShape::GeoBShape GeoBShape;
318 UInt nbVertexPerFacet = GeoBShape::S_numVertices;
319 UInt nbRidgePerFacet = GeoBShape::S_numRidges;
321 UInt nbDofPerVertex = M_refFE1->nbDofPerVertex();
322 UInt nbDofPerRidge = M_refFE1->nbDofPerRidge();
323 UInt nbDofPerFacet = M_refFE1->nbDofPerFacet();
325 UInt nbVertexPerElement = GeoShape::S_numVertices;
326 UInt nbRidgePerElement = GeoShape::S_numRidges;
328 UInt nbDofPerElement = M_refFE2->nbDof();
330 UInt nbVertexDofPerElement = nbVertexPerElement * nbDofPerVertex;
331 UInt nbRidgeDofPerElement = nbRidgePerElement * nbDofPerRidge;
333 ID ibF, iElAd, iFaEl, iVeEl, lDof, iEdEl;
337 std::vector<Real> vLoc ( nbDofPerElement * nbComp );
341 for ( Iterator i = M_facetToFacetConnectionList.begin(); i != M_facetToFacetConnectionList.end(); ++i )
346 iElAd = mesh2.boundaryFacet ( ibF ).firstAdjacentElementIdentity();
347 iFaEl = mesh2.boundaryFacet ( ibF ).firstAdjacentElementPosition();
350 for ( UInt icmp = 0; icmp < nbComp; ++icmp )
351 for ( ID idof = 0; idof < nbDofPerElement; ++idof )
353 vLoc[ icmp * nbDofPerElement + idof ] = v [ icmp * M_dof2->numTotalDof() + M_dof2->localToGlobalMap ( iElAd, idof ) ];
357 if ( nbDofPerVertex )
361 for ( ID iVeFa = 0; iVeFa < nbVertexPerFacet; ++iVeFa )
364 iVeEl = GeoShape::facetToPoint ( iFaEl, iVeFa );
367 for ( ID l = 0; l < nbDofPerVertex; ++l )
369 lDof = iVeEl * nbDofPerVertex + l;
372 x = M_refFE1->xi ( lDof );
373 y = M_refFE1->eta ( lDof );
374 z = M_refFE1->zeta ( lDof );
377 for ( UInt icmp = 0; icmp < nbComp; ++icmp )
382 for ( ID idof = 0; idof < nbDofPerElement; ++idof )
384 sum += vLoc[ icmp * nbDofPerElement + idof ] * M_refFE2->phi ( idof, x, y, z );
388 vI ( icmp * M_dof->numTotalDof() + M_dof->localToGlobalMap ( iElAd, lDof ) ) = sum;
399 for ( ID iEdFa = 0; iEdFa < nbRidgePerFacet; ++iEdFa )
402 iEdEl = GeoShape::faceToRidge ( iFaEl, iEdFa ).first;
405 for ( ID l = 0; l < nbDofPerRidge; ++l )
407 lDof = nbVertexDofPerElement + iEdEl * nbDofPerRidge + l;
410 x = M_refFE1->xi ( lDof );
411 y = M_refFE1->eta ( lDof );
412 z = M_refFE1->zeta ( lDof );
415 for ( UInt icmp = 0; icmp < nbComp; ++icmp )
420 for ( ID idof = 0; idof < nbDofPerElement; ++idof )
422 sum += vLoc[ icmp * nbDofPerElement + idof ] * M_refFE2->phi ( idof, x, y, z );
426 vI ( icmp * M_dof->numTotalDof() + M_dof->localToGlobalMap ( iElAd, lDof ) ) = sum;
433 for ( ID l = 0; l < nbDofPerFacet; ++l )
435 lDof = nbRidgeDofPerElement + nbVertexDofPerElement + iFaEl * nbDofPerFacet + l;
438 x = M_refFE1->xi ( lDof );
439 y = M_refFE1->eta ( lDof );
440 z = M_refFE1->zeta ( lDof );
443 for ( UInt icmp = 0; icmp < nbComp; ++icmp )
448 for ( ID idof = 0; idof < nbDofPerElement; ++idof )
450 sum += vLoc[ icmp * nbDofPerElement + idof ] * M_refFE2->phi ( idof, x, y, z );
454 vI ( icmp * M_dof->numTotalDof() + M_dof->localToGlobalMap ( iElAd, lDof ) ) = sum;
464 template <
typename MeshType>
465 void DOFInterface3Dto3D::updateFacetConnections (
const MeshType& mesh1,
const markerID_Type& flag1,
466 const MeshType& mesh2,
const markerID_Type& flag2,
const Real& tol,
const fct& coupled )
469 UInt bdnF1 = mesh1.numBoundaryFacets();
470 UInt bdnF2 = mesh2.numBoundaryFacets();
473 std::set<ID> facetsFlagged2;
476 typedef typename MeshType::facetShape_Type GeoBShape;
478 UInt nbVertexPerFacet = GeoBShape::S_numVertices;
480 std::vector<Real> v1 (nDimensions), v2 ( nDimensions );
481 std::vector< std::vector<Real> > vertexVector (nbVertexPerFacet);
487 for (
ID ibF2 = 0; ibF2 < bdnF2; ++ibF2 )
488 if ( flag2 == mesh2.boundaryFacet ( ibF2 ).markerID() )
490 facetsFlagged2.insert (ibF2);
494 for (
ID ibF1 = 0; ibF1 < bdnF1; ++ibF1 )
498 marker1 = mesh1.boundaryFacet ( ibF1 ).markerID();
501 if ( marker1 == flag1 )
505 for (
ID iVeFa = 0; iVeFa < nbVertexPerFacet; ++iVeFa )
511 v1[ j ] = mesh1.boundaryFacet ( ibF1 ).point ( iVeFa ).coordinate ( j );
513 vertexVector[iVeFa] = v1;
516 std::set<ID>::iterator it = facetsFlagged2.begin();
517 for (; it != facetsFlagged2.end(); ++it )
527 for ( ID j = 0; j < nDimensions; ++j )
529 v2[ j ] = mesh2.boundaryFacet ( ibF2 ).point ( iVeFa ).coordinate ( j );
537 matched = coupled ( vertexVector[ivefa], v2, tol );
539 while ( (++ivefa < nbVertexPerFacet) && !matched );
541 while ( (++iVeFa < nbVertexPerFacet) && matched);
545 std::pair<ID, ID> elc ( ibF1, ibF2 );
546 M_facetToFacetConnectionList.push_front ( elc );
547 facetsFlagged2.erase (it);
565 template <
typename Mesh>
566 void DOFInterface3Dto3D::updateDofConnections (
const Mesh& mesh1,
const DOF& dof1,
567 const Mesh& mesh2,
const DOF& dof2,
const Real& tol,
const fct& coupled,
Int const*
const flag3)
572 std::vector<Real> p1 ( nDimensions ), p2 ( nDimensions );
575 for ( Iterator i = M_facetToFacetConnectionList.begin(); i != M_facetToFacetConnectionList.end(); ++i )
578 feBd1.update ( mesh1.boundaryFacet ( i->first ), UPDATE_ONLY_CELL_NODES );
579 feBd2.update ( mesh2.boundaryFacet ( i->second ), UPDATE_ONLY_CELL_NODES );
582 std::vector<ID> localToGlobalMapOnBFacet1 = dof1.localToGlobalMapOnBdFacet (i->first);
583 std::vector<ID> localToGlobalMapOnBFacet2 = dof2.localToGlobalMapOnBdFacet (i->second);
586 MatrixSmall<6,4> FaceDof;
593 for (ID lDof1 = 0; lDof1 < localToGlobalMapOnBFacet1.size(); lDof1++){
595 feBd1.coorMap ( FaceDof[lDof1][0], FaceDof[lDof1][1], FaceDof[lDof1][2], feBd1.refFE().xi ( lDof1 ), feBd1.refFE().eta ( lDof1 ) );
598 FaceDof[lDof1][3] = mesh1.boundaryFacet ( i->first ).point ( lDof1 ).markerID ();
602 if ( localToGlobalMapOnBFacet1.size() > 3 ){
604 FaceDof[3][3] = ( FaceDof[0][3] == FaceDof[1][3] ) ? FaceDof[0][3] : 1439;
605 FaceDof[4][3] = ( FaceDof[1][3] == FaceDof[2][3] ) ? FaceDof[1][3] : 1439;
606 FaceDof[5][3] = ( FaceDof[0][3] == FaceDof[2][3] ) ? FaceDof[0][3] : 1439;
609 for (ID lDof1 = 0; lDof1 < localToGlobalMapOnBFacet1.size(); lDof1++)
612 ID gDof1 = localToGlobalMapOnBFacet1[lDof1];
614 p1[0] = FaceDof[lDof1][0];
615 p1[1] = FaceDof[lDof1][1];
616 p1[2] = FaceDof[lDof1][2];
618 if ( flag3 != 0 &&
static_cast < Int > (FaceDof[lDof1][3]) == *flag3 )
623 for (ID lDof2 = 0; lDof2 < localToGlobalMapOnBFacet2.size(); lDof2++)
625 ID gDof2 = localToGlobalMapOnBFacet2[lDof2];
626 feBd2.coorMap ( p2[0], p2[1], p2[2], feBd2.refFE().xi ( lDof2 ), feBd2.refFE().eta ( lDof2 ) );
628 if ( coupled ( p1, p2, tol ) )
630 std::pair<ID, ID> locDof ( gDof1, gDof2 );
631 M_dofToDofConnectionList.push_front ( locDof );
640 for ( Iterator i = M_dofToDofConnectionList.begin(); i != M_dofToDofConnectionList.end(); ++i )
642 M_localDofMap[ i->first ] = i->second;
646 M_dofToDofConnectionList.clear();
const ReferenceFE & boundaryFE() const
Getter for the boundary finite element.
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
A class for a finite element on a manifold.
int32_type Int
Generic integer data.
ID markerID_Type
markerID_Type is the type used to store the geometric entity marker IDs
double Real
Generic real data.
The class for a reference Lagrangian finite element.
const UInt nDimensions(NDIM)
uint32_type UInt
generic unsigned integer (used mainly for addressing)