46 #ifndef _DOFINTERFACE3DTO2D_HH 47 #define _DOFINTERFACE3DTO2D_HH 51 #include <lifev/core/LifeV.hpp> 53 #include <lifev/core/fem/DOFInterface.hpp> 54 #include <lifev/core/fem/DOFLocalPattern.hpp> 55 #include <lifev/core/fem/DOF.hpp> 56 #include <lifev/core/mesh/MarkerDefinitions.hpp> 67 class DOFInterface3Dto2D:
76 DOFInterface3Dto2D() :
101 template <
typename MeshType>
102 void update (
const MeshType& mesh1,
const markerID_Type& flag1 );
113 template <
typename MeshType>
114 void generate2DMesh ( std::string fname,
const MeshType& mesh1 )
const;
120 std::ostream& showMe (
bool verbose =
false, std::ostream& out = std::cout )
const ;
130 ID operator[] (
const UInt& i )
const;
133 DOFInterface3Dto2D& operator= (
const DOFInterface3Dto2D& dofi );
144 return M_interfaceFlag;
148 const bool& finalized()
const 163 ID vertex3Dto2D (
const ID& idpoint3D )
const;
170 template <
typename MeshType>
171 void updateFaceConnections (
const MeshType& mesh1,
const markerID_Type& flag1 );
177 template <
typename MeshType>
178 void updateVertices (
const MeshType& mesh1 );
185 template <
typename MeshType>
186 void updateDofConnections (
const MeshType& mesh1 );
206 std::vector< std::pair<ID, ID> > M_faceList;
212 std::list<ID> M_vertexPerFaceList;
218 std::list< std::pair<ID, ID> > M_vertexList;
235 void RemoveMultiple (
const std::list<ID>& list0, std::list< std::pair<ID, ID> >& listf );
242 template <
typename MeshType>
243 void DOFInterface3Dto2D::
248 updateFaceConnections ( mesh1, flag1 );
251 updateVertices ( mesh1 );
256 updateDofConnections ( mesh1 );
258 M_interfaceFlag = flag1;
263 template <
typename MeshType>
264 void DOFInterface3Dto2D::
265 generate2DMesh ( std::string fname,
const MeshType& mesh1 )
const 268 ASSERT_PRE ( M_finalized,
"The lists of vertices and faces must be finalized before generating the interface mesh." );
270 std::ofstream ofile ( fname.c_str() );
271 ASSERT ( ofile,
"Error: Output file cannot be open" );
277 typedef typename MeshType::FaceShape FaceShape;
278 UInt numVertexPerFace = FaceShape::S_numVertices;
280 ofile <<
"MeshVersionFormatted 1\n";
281 ofile <<
"Dimension 3\n";
284 ofile <<
"Vertices\n";
285 ofile << M_vertexList.size() <<
"\n";
288 for ( std::list< std::pair<ID, ID> >::const_iterator i2D = M_vertexList.begin(); i2D != M_vertexList.end(); ++i2D )
290 idpoint3D = i2D->first;
291 ofile << mesh1.pointList ( idpoint3D ).x() <<
" " 292 << mesh1.pointList ( idpoint3D ).y() <<
" " 293 << mesh1.pointList ( idpoint3D ).z() <<
" " 294 << mesh1.pointList ( idpoint3D ).markerID() << std::endl;
298 switch ( FaceShape::S_shape )
300 case FaceShape::QUAD:
301 ofile <<
"Quadrilaterals\n";
303 case FaceShape::TRIANGLE:
304 ofile <<
"Triangles\n";
307 ERROR_MSG (
"This shape is not implemented in myinterface!" );
310 ofile << M_faceList.size() <<
"\n";
313 for ( std::vector< std::pair<ID, ID> >::const_iterator i2D = M_faceList.begin(); i2D != M_faceList.end(); ++i2D )
315 idface3D = i2D->first;
317 for ( ID vertex = 0 ; vertex < numVertexPerFace ; ++ vertex )
319 idpoint3D = mesh1.boundaryFace ( idface3D ).point ( vertex ).id();
320 idpoint2D = vertex3Dto2D ( idpoint3D );
321 ofile << idpoint2D <<
" ";
323 ofile << mesh1.boundaryFace ( idface3D ).markerID() << std::endl;
331 template <
typename MeshType>
332 void DOFInterface3Dto2D::
336 UInt numBoundaryFace1 = mesh1.numBFaces();
343 for (
ID iBoundaryFace1 = 0; iBoundaryFace1 < numBoundaryFace1; ++iBoundaryFace1 )
347 marker1 = mesh1.boundaryFace ( iBoundaryFace1 ).markerID();
350 if ( marker1 == flag1 )
353 std::pair<ID, ID> fp ( iBoundaryFace1, fcounter );
354 M_faceList.push_back ( fp );
359 ASSERT ( M_faceList.size() == --fcounter,
360 "Local face counter and list size do not match (in face loop)." );
364 template <
typename MeshType>
365 void DOFInterface3Dto2D::
366 updateVertices (
const MeshType& mesh1 )
369 typedef typename MeshType::FaceShape GeoBShape;
371 UInt numVertexPerFace = GeoBShape::S_numVertices;
374 for ( std::vector< std::pair<ID, ID> >::iterator i = M_faceList.begin(); i != M_faceList.end(); ++i )
376 for ( ID jVertex = 0 ; jVertex < numVertexPerFace ; ++ jVertex )
378 M_vertexPerFaceList.push_back ( mesh1.boundaryFace ( i->first ).point ( jVertex ).id() );
382 RemoveMultiple ( M_vertexPerFaceList , M_vertexList );
385 M_vertexPerFaceList.clear();
389 template <
typename MeshType>
390 void DOFInterface3Dto2D::
391 updateDofConnections (
const MeshType& mesh1 )
393 typedef typename MeshType::VolumeShape GeoShape;
394 typedef typename MeshType::FaceShape GeoBShape;
396 UInt nbVertexPerFace = GeoBShape::S_numVertices;
397 UInt nbEdgePerFace = GeoBShape::S_numEdges;
403 UInt nbVertexPerElement = GeoShape::S_numVertices;
404 UInt nbEdgePerElement = GeoShape::S_numEdges;
406 UInt nDofElemV1 = nbVertexPerElement * nbDofPerVertex1;
407 UInt nDofElemE1 = nbEdgePerElement * nbDofPerEdge1;
409 ID iElAd1, iVeEl1, iFaEl1, iEdEl1, gDof1;
411 ID locDofCounter1 = 0;
413 std::map<ID, ID> locDofMap;
416 for ( std::vector< std::pair<ID, ID> >::iterator i = M_faceList.begin(); i != M_faceList.end(); ++i )
419 iElAd1 = mesh1.boundaryFace ( i->first ).firstAdjacentElementIdentity();
421 iFaEl1 = mesh1.boundaryFace ( i->first ).firstAdjacentElementPosition();
424 if ( nbDofPerVertex1 )
428 for ( ID iVeFa1 = 0; iVeFa1 < nbVertexPerFace; ++iVeFa1 )
431 iVeEl1 = GeoShape::faceToPoint ( iFaEl1, iVeFa1 );
434 for ( ID l = 0; l < nbDofPerVertex1; ++l )
437 gDof1 = M_dof1->localToGlobalMap ( iElAd1, iVeEl1 * nbDofPerVertex1 + l );
439 std::pair<ID, ID> locDof ( gDof1, locDofCounter1);
440 locDofMap.insert ( locDof );
452 for ( ID iEdFa1 = 0; iEdFa1 < nbEdgePerFace; ++iEdFa1 )
455 iEdEl1 = GeoShape::faceToEdge ( iFaEl1, iEdFa1 ).first;
458 for ( ID l = 0; l < nbDofPerEdge1; ++l )
461 gDof1 = M_dof1->localToGlobalMap ( iElAd1, nDofElemV1 + iEdEl1 * nbDofPerEdge1 + l );
463 std::pair<ID, ID> locDof ( gDof1, locDofCounter1 );
464 locDofMap.insert ( locDof );
472 for ( ID l = 0; l < nbDofPerFace1; ++l )
475 gDof1 = M_dof1->localToGlobalMap ( iElAd1, nDofElemE1 + nDofElemV1 + iFaEl1 * nbDofPerFace1 + l );
477 std::pair<ID, ID> locDof ( gDof1, locDofCounter1 );
478 locDofMap.insert ( locDof );
486 for ( std::map<ID, ID>::const_iterator it = locDofMap.begin(); it != locDofMap.end(); ++it, ++ii )
489 std::pair<ID, ID> _locDof (it->first, ii);
490 M_localDofMap.insert (_locDof);
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
const UInt & nbDofPerVertex() const
Return the number of degrees of freedom located on the vertices (0D structures)
ID markerID_Type
markerID_Type is the type used to store the geometric entity marker IDs
DOFLocalPattern - A class to store the "couplings" between the basis functions.
const UInt & nbDofPerEdge() const
Return the number of degrees of freedom located on the edges (1D structures)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
const UInt & nbDofPerFace() const
Return the number of degrees of freedom located on the faces (2D structures).