39 #define MESHUTILITY_H 1
45 #include <boost/numeric/ublas/matrix.hpp> 46 #include <boost/numeric/ublas/io.hpp> 49 #include <lifev/core/LifeV.hpp> 50 #include <lifev/core/util/Switch.hpp> 51 #include <lifev/core/array/VectorSmall.hpp> 52 #include <lifev/core/mesh/MeshElementBare.hpp> 53 #include <lifev/core/mesh/MarkerDefinitions.hpp> 54 #include <lifev/core/mesh/MeshEntity.hpp> 55 #include <lifev/core/mesh/MeshEntityContainer.hpp> 56 #include <lifev/core/array/EnumMapEpetra.hpp> 95 template <
typename MeshType>
136 ID point1Id, point2Id, point3Id, point4Id;
139 point1Id = face.point ( 0 ).localId();
140 point2Id = face.point ( 1 ).localId();
141 point3Id = face.point ( 2 ).localId();
144 point4Id = face.point ( 3 ).localId();
145 bareFace = ( makeBareFace ( point1Id, point2Id, point3Id, point4Id ) ).first;
149 bareFace = ( makeBareFace ( point1Id, point2Id, point3Id ) ).first;
151 return ( boundaryFaceContainerPtr->find ( bareFace ) != boundaryFaceContainerPtr->end() );
178 template <
typename MeshType>
223 ID point1Id, point2Id;
226 point1Id = edge.point ( 0 ).localId();
227 point2Id = edge.point ( 1 ).localId();
228 bareEdge = ( makeBareEdge ( point1Id, point2Id ) ).first;
229 return boundaryEdgeContainerPtr->find ( bareEdge ) != boundaryEdgeContainerPtr->end();
255 template <
typename MeshType>
278 meshPtr ( enquireBoundaryPoint.meshPtr )
364 Real const& z,
Real ret[ 3 ] )
const;
408 Real const& z,
Real ret[ 3 ] )
const;
445 template <
typename MeshType>
448 bool buildAllFaces =
false )
450 UInt point1Id, point2Id, point3Id, point4Id;
452 typename MeshType::elementShape_Type volumeShape;
453 typedef typename MeshType::volumes_Type volumeContainer_Type;
454 temporaryFaceContainer_Type::iterator faceContainerIterator;
457 boundaryFaceContainer.clear();
460 internalFaces.clear();
462 numInternalFaces = 0;
464 for (
typename volumeContainer_Type::const_iterator volumeContainerIterator = mesh.volumeList.begin();
465 volumeContainerIterator != mesh.volumeList.end(); ++volumeContainerIterator )
467 for (
ID jFaceLocalId = 0; jFaceLocalId < mesh.numLocalFaces(); ++jFaceLocalId )
469 point1Id = volumeShape.faceToPoint ( jFaceLocalId, 0 );
470 point2Id = volumeShape.faceToPoint ( jFaceLocalId, 1 );
471 point3Id = volumeShape.faceToPoint ( jFaceLocalId, 2 );
473 point1Id = ( volumeContainerIterator->point ( point1Id ) ).localId();
474 point2Id = ( volumeContainerIterator->point ( point2Id ) ).localId();
475 point3Id = ( volumeContainerIterator->point ( point3Id ) ).localId();
476 if ( MeshType::facetShape_Type::S_numVertices == 4 )
478 point4Id = volumeShape.faceToPoint ( jFaceLocalId, 3 );
479 point4Id = ( volumeContainerIterator->point ( point4Id ) ).localId();
480 bareFace = ( makeBareFace ( point1Id, point2Id, point3Id, point4Id ) ).first;
484 bareFace = ( makeBareFace ( point1Id, point2Id, point3Id ) ).first;
487 if ( ( faceContainerIterator = boundaryFaceContainer.find ( bareFace ) ) == boundaryFaceContainer.end() )
489 boundaryFaceContainer.insert (
490 std::make_pair ( bareFace, std::make_pair ( volumeContainerIterator->localId(), jFaceLocalId ) ) );
494 if ( buildAllFaces && point1Id > point2Id )
496 internalFaces.insert (
497 ( std::make_pair ( bareFace, std::make_pair ( volumeContainerIterator->localId(), jFaceLocalId ) ) ) );
499 boundaryFaceContainer.erase ( faceContainerIterator );
504 return boundaryFaceContainer.size();
527 template <
typename MeshType>
530 UInt& numInternalFaces )
533 return findFaces ( mesh, boundaryFaceContainer, numInternalFaces, dummy,
false );
554 template <
typename MeshType>
557 UInt point1Id, point2Id;
559 typedef typename MeshType::facetShape_Type facetShape_Type;
560 typedef typename MeshType::faces_Type faceContainer_Type;
563 if ( ! mesh.hasFaces() )
569 boundaryEdgeContainer.clear();
572 for (
typename faceContainer_Type::const_iterator faceContainerIterator = mesh.faceList.begin();
573 faceContainerIterator != mesh.faceList.begin() + mesh.numBFaces(); ++faceContainerIterator )
575 for (
ID jEdgeLocalId = 0; jEdgeLocalId < mesh.numLocalEdgesOfFace(); ++jEdgeLocalId )
577 point1Id = facetShape_Type::edgeToPoint ( jEdgeLocalId, 0 );
578 point2Id = facetShape_Type::edgeToPoint ( jEdgeLocalId, 1 );
580 point1Id = ( faceContainerIterator->point ( point1Id ) ).localId();
581 point2Id = ( faceContainerIterator->point ( point2Id ) ).localId();
582 bareEdge = ( makeBareEdge ( point1Id, point2Id ) ).first;
583 boundaryEdgeContainer.insert (
584 std::make_pair ( bareEdge, std::make_pair ( faceContainerIterator->localId(), jEdgeLocalId ) ) );
587 return boundaryEdgeContainer.size();
612 template <
typename MeshType>
617 UInt point1Id, point2Id;
619 typedef typename MeshType::elementShape_Type volumeShape_Type;
620 typedef typename MeshType::volumes_Type volumeContainer_Type;
625 internalEdgeContainer.clear();
626 internalEdgeContainer.swap (temporaryEdgeContainer);
628 for (
typename volumeContainer_Type::const_iterator volumeContainerIterator = mesh.volumeList.begin();
629 volumeContainerIterator != mesh.volumeList.end(); ++volumeContainerIterator )
631 for (
ID jEdgeLocalId = 0; jEdgeLocalId < mesh.numLocalEdges(); ++jEdgeLocalId )
633 point1Id = volumeShape_Type::edgeToPoint ( jEdgeLocalId, 0 );
634 point2Id = volumeShape_Type::edgeToPoint ( jEdgeLocalId, 1 );
636 point1Id = ( volumeContainerIterator->point ( point1Id ) ).localId();
637 point2Id = ( volumeContainerIterator->point ( point2Id ) ).localId();
638 bareEdge = ( makeBareEdge ( point1Id, point2Id ) ).first;
639 if ( boundaryEdgeContainer.find ( bareEdge ) == boundaryEdgeContainer.end() )
640 internalEdgeContainer.insert
641 ( std::make_pair ( bareEdge, std::make_pair ( volumeContainerIterator->localId(), jEdgeLocalId ) ) );
644 return internalEdgeContainer.size();
673 template <
typename MeshElementMarkedType>
676 ASSERT_PRE ( MeshElementMarkedType::S_nDimensions > 0,
677 "A MeshElementMarked with ndim == 0 cannot inherit marker IDs" );
679 geoElement.setMarkerID ( geoElement.point ( 0 ).markerID() );
680 for (
ID jPointId = 1; jPointId < MeshElementMarkedType::S_numVertices; ++jPointId )
682 geoElement.setStrongerMarker ( geoElement.point ( jPointId ).markerID() );
684 return geoElement.markerID();
702 template <
typename MeshElementMarkedType>
705 ASSERT_PRE ( MeshElementMarkedType::S_nDimensions > 0,
706 "A MeshElementMarked with ndim == 0 cannot inherit marker IDs" );
708 geoElement.setMarkerID ( geoElement.point ( 0 ).markerID() );
709 for (
ID jPointId = 1; jPointId < MeshElementMarkedType::S_numVertices; ++jPointId )
711 geoElement.setWeakerMarkerID ( geoElement.point ( jPointId ).markerID() );
713 return geoElement.markerID();
729 template <
typename MeshType>
733 typedef std::set <BareEdge, cmpBareItem<BareEdge> > localTemporaryEdgeContainer_Type;
734 localTemporaryEdgeContainer_Type localTemporaryEdgeContainer;
735 UInt point1Id, point2Id;
737 typename MeshType::facetShape_Type faceShape;
738 typedef typename MeshType::faces_Type faceContainer_Type;
739 typedef typename MeshType::face_Type face_Type;
740 localTemporaryEdgeContainer_Type::iterator edgeContainerIterator;
742 typename faceContainer_Type::const_iterator faceContainerIterator = mesh.faceList.begin();
744 for (
UInt kFaceId = 0; kFaceId < mesh.numBFaces(); ++kFaceId )
746 std::ostringstream errorStream;
747 errorStream <<
" Trying to get not existing face" 748 << kFaceId <<
" " << mesh.numBFaces();
749 ASSERT ( faceContainerIterator != mesh.faceList.end(), errorStream.str().c_str() );
751 for (
ID jEdgeLocalId = 0; jEdgeLocalId < face_Type::S_numEdges; ++jEdgeLocalId )
753 point1Id = faceShape.edgeToPoint ( jEdgeLocalId, 0 );
754 point2Id = faceShape.edgeToPoint ( jEdgeLocalId, 1 );
756 point1Id = ( faceContainerIterator->point ( point1Id ) ).localId();
757 point2Id = ( faceContainerIterator->point ( point2Id ) ).localId();
758 bareEdge = ( makeBareEdge ( point1Id, point2Id ) ).first;
760 if ( ( edgeContainerIterator = localTemporaryEdgeContainer.find ( bareEdge ) )
761 == localTemporaryEdgeContainer.end() )
763 localTemporaryEdgeContainer.insert ( bareEdge );
768 localTemporaryEdgeContainer.erase ( edgeContainerIterator );
771 ++faceContainerIterator;
773 return localTemporaryEdgeContainer.size();
784 template <
typename MeshEntityListType>
787 typedef typename MeshEntityListType::const_iterator MeshEntityListTypeConstIterator_Type;
789 for ( MeshEntityListTypeConstIterator_Type meshEntityListIterator = meshEntityList.begin();
790 meshEntityListIterator != meshEntityList.end(); ++meshEntityListIterator )
792 ok = ( ok & meshEntityListIterator->isMarkerSet() );
815 template <
typename MeshType>
818 std::ostream& = std::cerr,
bool verbose =
true )
820 verbose = verbose && ( mesh.comm()->MyPID() == 0 );
822 typename MeshType::edge_Type* edgePtr = 0;
826 logStream <<
"NEW EDGE MARKER MAP" << std::endl
827 <<
" ID->New Marker" << std::endl;
829 for (
ID kEdgeId = 0; kEdgeId < mesh.numBEdges(); ++kEdgeId )
831 edgePtr = & ( mesh.edge ( kEdgeId ) );
832 if ( edgePtr->isMarkerUnset() )
834 inheritPointsWeakerMarker ( *edgePtr );
837 logStream << edgePtr->localId() <<
" -> " << edgePtr->markerID();
839 if ( ++counter % 3 == 0 )
841 logStream << std::endl;
848 logStream << std::endl;
867 template <
typename MeshType>
870 std::ostream& = std::cerr,
bool verbose =
true )
872 verbose = verbose && ( mesh.comm()->MyPID() == 0 );
874 typename MeshType::face_Type* facePtr = 0;
879 logStream <<
"**** NEW FACE MARKER MAP **************" << std::endl;
880 logStream <<
" Face ID -> New Marker\tFace ID -> New Marker\tFace ID -> New Marker" << std::endl;
883 for (
UInt kFaceId = 0; kFaceId < mesh.numBFaces(); ++kFaceId )
885 facePtr = & ( mesh.face ( kFaceId ) );
886 if ( facePtr->isMarkerUnset() )
888 inheritPointsWeakerMarker ( *facePtr );
891 logStream << facePtr->localId() <<
" -> " << facePtr->markerID();
893 if ( ++counter % 3 == 0 )
895 logStream << std::endl;
902 logStream << std::endl;
921 template <
typename MeshType>
924 std::ostream& = std::cerr,
bool verbose =
false )
926 verbose = verbose && ( mesh.comm()->MyPID() == 0 );
929 std::vector<
bool> isDefinedPointMarker ( mesh.storedPoints(),
false );
931 typedef typename MeshType::points_Type::iterator pointContainerIterator_Type;
932 typedef typename MeshType::facetShape_Type faceShape_Type;
934 std::vector<
bool>::iterator isDefinedPointMarkerIterator = isDefinedPointMarker.begin();
936 for ( pointContainerIterator_Type pointContainerIterator = mesh.pointList.begin();
937 pointContainerIterator != mesh.pointList.end(); ++pointContainerIterator )
939 * ( isDefinedPointMarkerIterator++ ) = pointContainerIterator->isMarkerSet();
942 typename MeshType::face_Type* facetPtr = 0;
943 for (
UInt kFacetId = 0; kFacetId < mesh.numBFaces(); ++kFacetId )
945 facetPtr = & ( mesh.boundaryFacet ( kFacetId ) );
946 if ( facetPtr->isMarkerSet() )
948 for (
UInt jPointId = 0; jPointId < faceShape_Type::S_numPoints; ++jPointId )
950 if ( !isDefinedPointMarker[ facetPtr->point ( jPointId ).localId() ] )
954 facetPtr->setStrongerMarkerIDAtPoint ( jPointId, facetPtr->markerID() );
960 for (
UInt i = 0; i < mesh.storedPoints(); ++i )
961 if (!mesh.point (i).boundary() && !isDefinedPointMarker[i])
963 mesh.point (i).setMarkerID (mesh.markerID() );
969 logStream <<
"**** NEW POINT MARKER MAP **************" << std::endl;
970 logStream <<
" Point ID -> New Marker\tPoint ID -> New Marker\tPoint ID -> New Marker" << std::endl;
971 isDefinedPointMarkerIterator = isDefinedPointMarker.begin();
972 for ( pointContainerIterator_Type pointContainerIterator = mesh.pointList.begin();
973 pointContainerIterator != mesh.pointList.end(); ++pointContainerIterator )
975 if ( *isDefinedPointMarkerIterator++ )
977 logStream << pointContainerIterator->localId() <<
" -> " <<
978 pointContainerIterator->markerID();
982 logStream << std::endl;
986 logStream << std::endl;
1003 template <
typename MeshEntityListType>
1004 bool checkId (
const MeshEntityListType& meshEntityList )
1006 typedef typename MeshEntityListType::const_iterator MeshEntityListTypeConstIterator_Type;
1009 for ( MeshEntityListTypeConstIterator_Type meshEntityListIterator = meshEntityList.begin();
1010 meshEntityListIterator != meshEntityList.end() && ok; ++meshEntityListIterator, ++counter )
1012 ok = ok && ( meshEntityListIterator->localId() == counter );
1025 template <
typename MeshEntityListType>
1026 void fixId ( MeshEntityListType& meshEntityList )
1029 typedef typename MeshEntityListType::iterator Iter;
1030 for ( Iter meshEntityListIterator = meshEntityList.begin();
1031 meshEntityListIterator != meshEntityList.end(); ++meshEntityListIterator )
1033 meshEntityListIterator->setLocalId ( counter++ );
1045 template <
typename MeshType>
1050 UInt boundaryPointCounter ( 0 );
1051 UInt boundaryVertexCounter ( 0 );
1053 mesh._bPoints.clear();
1055 for (
UInt kPointId = 0; kPointId < mesh.numVertices(); ++kPointId )
1057 if ( mesh.isBoundaryPoint ( kPointId ) )
1059 ++boundaryPointCounter;
1060 ++boundaryVertexCounter;
1064 for (
UInt kPointId = mesh.numVertices(); kPointId < mesh.storedPoints(); ++kPointId )
1066 if ( mesh.isBoundaryPoint ( kPointId ) )
1068 ++boundaryPointCounter;
1072 mesh.numBVertices() = boundaryVertexCounter;
1073 mesh.setNumBPoints ( boundaryPointCounter );
1074 mesh._bPoints.clear();
1075 mesh._bPoints.reserve ( boundaryPointCounter );
1077 for (
UInt kPointId = 0; kPointId < mesh.storedPoints(); ++kPointId )
1079 if ( mesh.isBoundaryPoint ( kPointId ) )
1081 mesh._bPoints.push_back ( &mesh.point ( kPointId ) );
1101 template <
typename MeshType>
1104 std::ostream& = std::cerr,
bool verbose =
true )
1106 verbose = verbose && ( mesh.comm()->MyPID() == 0 );
1108 ASSERT_PRE ( mesh.numPoints() > 0,
"The point list should not be empty" );
1110 "The boundary faces list should not be empty" );
1112 typedef typename MeshType::facetShape_Type faceShape_Type;
1116 logStream <<
"Fixing BPoints" << std::endl;
1118 std::vector<
bool> boundaryPoints (mesh.numPoints(),
false);
1122 if (mesh.storedPoints() == mesh.numVertices() )
1124 numitems = faceShape_Type::S_numVertices;
1128 numitems = faceShape_Type::S_numPoints;
1131 for (
UInt kFaceId = 0; kFaceId < mesh.numBFaces(); ++kFaceId )
1132 for (
UInt jPointId = 0; jPointId < numitems; ++jPointId )
1134 boundaryPoints[mesh.boundaryFacet (kFaceId).point (jPointId).localId()] =
true;
1136 for (
ID kPointId = 0; kPointId < mesh.storedPoints() ; ++kPointId )
1137 if (boundaryPoints[kPointId])
1146 boundaryPoints.clear();
1147 std::vector<
bool>().swap (boundaryPoints);
1149 setBoundaryPointsCounters ( mesh );
1201 template <
class MeshType>
1203 std::ostream& logStream,
1204 std::ostream& errorStream,
1207 UInt& numBoundaryFaces,
1208 bool verbose =
false,
1211 verbose = verbose && ( mesh.comm()->MyPID() == 0 );
1212 typedef typename MeshType::faces_Type faceContainer_Type;
1214 UInt point1Id, point2Id, point3Id, point4Id;
1216 typename faceContainer_Type::iterator faceContainerIterator;
1218 temporaryFaceContainer_Type::iterator boundaryFaceContainerIterator;
1219 UInt numInternalFaces;
1220 bool externalContainerIsProvided (
false );
1222 if ( (externalContainerIsProvided = ( externalFaceContainer != 0 ) ) )
1224 boundaryFaceContainerPtr = externalFaceContainer;
1225 numBoundaryFaces = boundaryFaceContainerPtr->size();
1230 numBoundaryFaces = findBoundaryFaces ( mesh, *boundaryFaceContainerPtr, numInternalFaces );
1231 numFaces = numBoundaryFaces + numInternalFaces;
1235 bool notEnough = mesh.storedFaces() < numBoundaryFaces;
1241 errorStream <<
"WARNING: number of B. Faces stored smaller" << std::endl;
1244 logStream <<
"WARNING: number of B. Faces stored smaller" << std::endl;
1246 errorStream <<
" than the number of boundaryFaces found and build is not set" 1248 errorStream <<
"ABORT condition in rearrangeFaces" << std::endl;
1253 if ( mesh.numBFaces() == 0 )
1255 errorStream <<
"ERROR: Boundary Element counter was not set" << std::endl;
1258 logStream <<
"ERROR: Boundary Element counter was not set" << std::endl;
1260 errorStream <<
"I Cannot proceed because the situation is ambiguous" 1262 errorStream <<
"Please check and eventually either: (a) call buildFaces()" << std::endl;
1263 errorStream <<
"or (b) set the correct number of boundaryFaces in the mesh using mesh.numBFaces()" << std::endl;
1264 errorStream <<
"ABORT" << std::endl;
1265 sw
.create ( "BELEMENT_COUNTER_UNSET", true );
1269 if ( mesh.numBFaces() != numBoundaryFaces )
1271 errorStream <<
"WARNING: Boundary face counter in mesh is set to " 1272 << mesh.numBFaces() << std::endl;
1273 errorStream <<
" while I have found " << numBoundaryFaces
1274 <<
" boundary elements in mesh." << std::endl;
1275 errorStream <<
" Please check... I continue anyway" << std::endl;
1276 sw
.create ( "BFACE_COUNTER_MISMATCH", true );
1280 for ( faceContainerIterator = mesh.faceList.begin(); faceContainerIterator != mesh.faceList.end();
1281 ++faceContainerIterator )
1283 point1Id = ( faceContainerIterator->point ( 0 ) ).localId();
1284 point2Id = ( faceContainerIterator->point ( 1 ) ).localId();
1285 point3Id = ( faceContainerIterator->point ( 2 ) ).localId();
1287 if ( MeshType::facetShape_Type::S_numVertices == 4 )
1289 point4Id = ( faceContainerIterator->point ( 3 ) ).localId();
1290 bareFace = ( makeBareFace ( point1Id, point2Id, point3Id, point4Id ) ).first;
1294 bareFace = ( makeBareFace ( point1Id, point2Id, point3Id ) ).first;
1296 boundaryFaceContainerIterator = boundaryFaceContainerPtr->find ( bareFace );
1297 if ( boundaryFaceContainerIterator == boundaryFaceContainerPtr->end() )
1356 template <
class MeshType>
1358 std::ostream& logStream,
1359 std::ostream& errorStream,
1362 UInt& numBoundaryFaces,
1364 bool verbose =
false,
1367 verbose = verbose && ( mesh.comm()->MyPID() == 0 );
1368 typedef typename MeshType::volume_Type volume_Type;
1369 typedef typename MeshType::faces_Type faceContainer_Type;
1370 typedef typename MeshType::face_Type face_Type;
1372 UInt point1Id, point2Id, point3Id, point4Id;
1374 volume_Type* volumePtr;
1375 typename faceContainer_Type::iterator faceContainerIterator;
1376 typename MeshType::elementShape_Type volumeShape;
1378 temporaryFaceContainer_Type::iterator boundaryFaceContainerIterator;
1379 std::pair<
ID,
ID> volumeIdToLocalFaceIdPair;
1382 UInt numInternalFaces;
1383 bool notfound (
false );
1384 bool externalContainerIsProvided (
false );
1386 if ( (externalContainerIsProvided = ( externalFaceContainer != 0 ) ) )
1388 boundaryFaceContainerPtr = externalFaceContainer;
1389 numBoundaryFaces = boundaryFaceContainerPtr->size();
1394 numBoundaryFaces = findBoundaryFaces ( mesh, *boundaryFaceContainerPtr, numInternalFaces );
1395 numFaces = numBoundaryFaces + numInternalFaces;
1399 bool notEnough = mesh.storedFaces() < numBoundaryFaces;
1405 errorStream <<
"WARNING: number of B. Faces stored smaller" << std::endl;
1406 errorStream <<
" than the number of boundaryFaces found and build is not set" 1408 errorStream <<
"POSSIBLE ERROR" << std::endl;
1412 if ( mesh.numBFaces() == 0 )
1414 errorStream <<
"ERROR: Boundary Element counter was not set" << std::endl;
1415 errorStream <<
"I Cannot proceed because the situation is ambiguous" 1417 errorStream <<
"Please check and eventually either: (a) call buildBoundaryFaces()" << std::endl;
1418 errorStream <<
"or (b) set the correct number of boundaryFaces in the mesh using mesh.numBFaces()" << std::endl;
1419 errorStream <<
"ABORT" << std::endl;
1423 if ( mesh.numBFaces() != numBoundaryFaces )
1425 errorStream <<
"WARNING: Boundary face counter in mesh is set to " 1426 << mesh.numBFaces() << std::endl;
1427 errorStream <<
" while I have found " << numBoundaryFaces
1428 <<
" boundary elements in mesh." << std::endl;
1429 errorStream <<
" Please check... I continue anyway" << std::endl;
1430 sw
.create ( "BFACE_COUNTER_MISMATCH", true );
1435 logStream <<
"**** Fixed Marker Flags for Boundary Faces ***" << std::endl;
1436 logStream <<
" (it only contains those that were fixed because unset !)" 1438 logStream <<
"id->marker id->marker id->marker" << std::endl;
1443 faceContainerIterator = mesh.faceList.begin();
1444 for (
UInt facid = 0; facid < mesh.numBFaces(); ++facid )
1446 point1Id = ( faceContainerIterator->point ( 0 ) ).localId();
1447 point2Id = ( faceContainerIterator->point ( 1 ) ).localId();
1448 point3Id = ( faceContainerIterator->point ( 2 ) ).localId();
1449 if ( MeshType::facetShape_Type::S_numVertices == 4 )
1451 point4Id = ( faceContainerIterator->point ( 3 ) ).localId();
1452 bareFace = ( makeBareFace ( point1Id, point2Id, point3Id, point4Id ) ).first;
1456 bareFace = ( makeBareFace ( point1Id, point2Id, point3Id ) ).first;
1458 boundaryFaceContainerIterator = boundaryFaceContainerPtr->find ( bareFace );
1459 if ( boundaryFaceContainerIterator == boundaryFaceContainerPtr->end() )
1463 if ( MeshType::facetShape_Type::S_numVertices == 3 )
1465 errorStream <<
"Face " << point1Id <<
" " << point2Id <<
" " << point3Id;
1469 errorStream <<
"Face " << point1Id <<
" " << point2Id <<
" " << point3Id <<
" " << point4Id;
1471 errorStream <<
" stored as boundary face, it's not!" << std::endl;
1477 volumeIdToLocalFaceIdPair = boundaryFaceContainerIterator->second;
1478 volumeId = volumeIdToLocalFaceIdPair.first;
1479 volumePtr = &mesh.volume ( volumeId );
1480 jFaceLocalId = volumeIdToLocalFaceIdPair.second;
1482 for (
UInt kPointId = 0; kPointId < face_Type::S_numPoints; ++kPointId )
1484 faceContainerIterator->setPoint ( kPointId, volumePtr->point ( volumeShape.faceToPoint ( jFaceLocalId, kPointId ) ) );
1487 faceContainerIterator->firstAdjacentElementIdentity() = volumeId;
1488 faceContainerIterator->firstAdjacentElementPosition() = jFaceLocalId;
1489 faceContainerIterator->secondAdjacentElementIdentity() =
NotAnId;
1490 faceContainerIterator->secondAdjacentElementPosition() =
NotAnId;
1492 if ( faceContainerIterator->isMarkerUnset() )
1494 inheritPointsWeakerMarker ( *faceContainerIterator );
1497 logStream << faceContainerIterator->localId() <<
" -> " <<
1498 faceContainerIterator->markerID();
1500 if ( ++counter % 3 == 0 )
1502 logStream << std::endl;
1507 boundaryFaceContainerPtr->erase ( boundaryFaceContainerIterator );
1509 ++faceContainerIterator;
1512 if ( !externalContainerIsProvided )
1514 delete boundaryFaceContainerPtr;
1519 errorStream <<
"WARNING: At least one boundary face has not been found on the list stored in MeshType\n";
1525 logStream << std::endl <<
" ***** END OF LIST ****" << std::endl;
1530 if ( mesh.numFaces() != numFaces )
1532 errorStream <<
"WARNING: faces counter in mesh should be " << numFaces
1534 errorStream <<
" (boundaryFaceContainerPtr->size()+numInternalFaces)" << std::endl;
1535 errorStream <<
" it is instead " << mesh.numFaces() << std::endl;
1538 mesh.setLinkSwitch ( std::string (
"HAS_BOUNDARY_FACETS" ) );
1587 template <
class MeshType>
1589 std::ostream& logStream,
1590 std::ostream& errorStream,
1591 UInt& numBoundaryFaces,
1592 UInt& numInternalFaces,
1593 bool buildBoundaryFaces =
true,
1594 bool buildInternalFaces =
false,
1595 bool verbose =
false,
1598 verbose = verbose && ( mesh.comm()->MyPID() == 0 );
1599 UInt point1Id, point2Id, point3Id, point4Id;
1600 typename MeshType::elementShape_Type volumeShape;
1601 typedef typename MeshType::volumes_Type volumeContainer_Type;
1602 typedef typename MeshType::volume_Type volume_Type;
1603 typedef typename MeshType::face_Type face_Type;
1604 volume_Type* volumePtr;
1606 temporaryFaceContainer_Type::iterator boundaryFaceContainerIterator;
1607 bool externalContainerIsProvided (
false );
1609 std::pair<
ID,
ID> volumeIdToLocalFaceIdPair;
1610 ID jFaceLocalId, newFaceId;
1612 std::map<BareFace, ID> existingFacesMap;
1613 std::map<BareFace, ID>::iterator existingFacesMap_It;
1614 std::pair<std::map<BareFace, ID>::iterator,
bool> existingFacesMap_insert;
1615 bool faceExists (
false);
1617 if ( (externalContainerIsProvided = ( externalFaceContainer != 0 ) ) )
1619 boundaryFaceContainerPtr = externalFaceContainer;
1620 numBoundaryFaces = boundaryFaceContainerPtr->size();
1625 numBoundaryFaces = findBoundaryFaces ( mesh, *boundaryFaceContainerPtr, numInternalFaces );
1628 for (
UInt jFaceId = 0; jFaceId < mesh.faceList.size(); ++jFaceId )
1630 point1Id = ( mesh.faceList[ jFaceId ].point ( 0 ) ).localId();
1631 point2Id = ( mesh.faceList[ jFaceId ].point ( 1 ) ).localId();
1632 point3Id = ( mesh.faceList[ jFaceId ].point ( 2 ) ).localId();
1633 if ( MeshType::facetShape_Type::S_numVertices == 4 )
1635 point4Id = ( mesh.faceList[ jFaceId ].point ( 3 ) ).localId();
1636 existingFacesMap_insert = existingFacesMap.insert (
1637 std::make_pair ( makeBareFace ( point1Id, point2Id, point3Id, point4Id).first, jFaceId )
1643 existingFacesMap_insert = existingFacesMap.insert (
1644 std::make_pair ( makeBareFace ( point1Id, point2Id, point3Id).first, jFaceId )
1647 if (! existingFacesMap_insert.second)
1649 errorStream <<
"ERROR in BuildFaces. Mesh stores two identical faces" << std::endl;
1650 if ( !externalContainerIsProvided )
1652 delete boundaryFaceContainerPtr;
1659 if ( buildBoundaryFaces )
1661 mesh.setNumBFaces ( numBoundaryFaces );
1663 if ( !buildInternalFaces )
1665 mesh.setMaxNumFaces ( std::max (numBoundaryFaces,
static_cast<UInt> (mesh.faceList.size() ) ),
false );
1666 mesh.setNumFaces ( numInternalFaces + numBoundaryFaces );
1670 mesh.setMaxNumFaces ( numInternalFaces + numBoundaryFaces,
true );
1675 if ( buildBoundaryFaces )
1680 logStream <<
"**** Marker Flags for Newly Created Boundary Faces ***" 1682 logStream <<
"id->marker id->marker id->marker" << std::endl;
1685 for ( boundaryFaceContainerIterator = boundaryFaceContainerPtr->begin();
1686 boundaryFaceContainerIterator != boundaryFaceContainerPtr->end(); ++boundaryFaceContainerIterator )
1688 existingFacesMap_It = existingFacesMap.find (boundaryFaceContainerIterator->first);
1689 if (existingFacesMap_It != existingFacesMap.end() )
1692 face = mesh.faceList[existingFacesMap_It->second];
1693 existingFacesMap.erase (existingFacesMap_It);
1699 face.setId ( mesh.faceList.size() );
1701 volumeIdToLocalFaceIdPair = boundaryFaceContainerIterator->second;
1702 volumeId = volumeIdToLocalFaceIdPair.first;
1703 volumePtr = &mesh.volume ( volumeId );
1704 jFaceLocalId = volumeIdToLocalFaceIdPair.second;
1706 for ( UInt kPointId = 0; kPointId < face_Type::S_numPoints; ++kPointId )
1708 face.setPoint ( kPointId, volumePtr->point ( volumeShape.faceToPoint ( jFaceLocalId, kPointId ) ) );
1711 face.firstAdjacentElementIdentity() = volumeId;
1712 face.firstAdjacentElementPosition() = jFaceLocalId;
1713 face.secondAdjacentElementIdentity() = NotAnId;
1714 face.secondAdjacentElementPosition() = NotAnId;
1716 if ( face.isMarkerUnset() )
1718 inheritPointsWeakerMarker ( face );
1720 face.setBoundary (
true);
1724 newFaceId = face.localId();
1725 mesh.setFace (face, newFaceId);
1730 newFaceId = mesh.addFace ( face).localId();
1734 if ( newFaceId % 3 == 0 )
1736 logStream << std::endl;
1738 logStream << newFaceId <<
" -> " << face.markerID();
1742 mesh.setLinkSwitch ( std::string (
"HAS_BOUNDARY_FACETS" ) );
1743 if ( ! buildInternalFaces )
1745 mesh.unsetLinkSwitch ( std::string (
"HAS_ALL_FACETS" ) );
1747 mesh.setLinkSwitch ( std::string (
"FACETS_HAVE_ADIACENCY" ) );
1750 if ( !externalContainerIsProvided )
1752 delete boundaryFaceContainerPtr;
1755 for (existingFacesMap_It = existingFacesMap.begin(); existingFacesMap_It != existingFacesMap.end();
1756 ++existingFacesMap_It)
1758 mesh.faceList[existingFacesMap_It->second].setBoundary (
false);
1763 if (!existingFacesMap.empty() )
1768 if ( ! buildInternalFaces )
1772 mesh.faceList.trim();
1779 if ( !buildBoundaryFaces )
1781 if ( mesh.storedFaces() < mesh.numBFaces() )
1783 errorStream <<
"ERROR: mesh has not boundary faces, cannot just create internal ones!!!" << std::endl;
1784 errorStream <<
"ABORT CONDITION" << std::endl;
1800 std::pair<
UInt,
bool> faceIdToBoolPair;
1802 existingFacesMap.clear();
1803 for (
UInt jFaceId = 0; jFaceId < mesh.faceList.size(); ++jFaceId )
1805 point1Id = ( mesh.faceList[ jFaceId ].point ( 0 ) ).localId();
1806 point2Id = ( mesh.faceList[ jFaceId ].point ( 1 ) ).localId();
1807 point3Id = ( mesh.faceList[ jFaceId ].point ( 2 ) ).localId();
1808 if ( MeshType::facetShape_Type::S_numVertices == 4 )
1810 point4Id = ( mesh.faceList[ jFaceId ].point ( 3 ) ).localId();
1811 _face = makeBareFace ( point1Id, point2Id, point3Id, point4Id );
1815 _face = makeBareFace ( point1Id, point2Id, point3Id );
1819 if (mesh.faceList[ jFaceId ].boundary() )
1821 bareFaceHandler.addIfNotThere ( _face.first );
1826 existingFacesMap.insert (std::make_pair (_face.first, jFaceId) );
1829 if (bareFaceHandler.howMany() > numBoundaryFaces)
1831 errorStream <<
"ERROR in BuildFaces. Not all boundary faces found, very strange" << std::endl;
1832 errorStream <<
"ABORT CONDITION" << std::endl;
1836 for (
typename volumeContainer_Type::iterator volumeContainerIterator = mesh.volumeList.begin();
1837 volumeContainerIterator != mesh.volumeList.end(); ++volumeContainerIterator )
1839 volumeId = volumeContainerIterator->localId();
1840 for (
UInt jFaceLocalId = 0; jFaceLocalId < mesh.numLocalFaces(); jFaceLocalId++ )
1842 point1Id = volumeShape.faceToPoint ( jFaceLocalId, 0 );
1843 point2Id = volumeShape.faceToPoint ( jFaceLocalId, 1 );
1844 point3Id = volumeShape.faceToPoint ( jFaceLocalId, 2 );
1846 point1Id = ( volumeContainerIterator->point ( point1Id ) ).localId();
1847 point2Id = ( volumeContainerIterator->point ( point2Id ) ).localId();
1848 point3Id = ( volumeContainerIterator->point ( point3Id ) ).localId();
1849 if ( MeshType::facetShape_Type::S_numVertices == 4 )
1851 point4Id = volumeShape.faceToPoint ( jFaceLocalId, 3 );
1852 point4Id = ( volumeContainerIterator->point ( point4Id ) ).localId();
1853 _face = makeBareFace ( point1Id, point2Id, point3Id, point4Id );
1857 _face = makeBareFace ( point1Id, point2Id, point3Id );
1859 faceIdToBoolPair = bareFaceHandler.addIfNotThere ( _face.first );
1860 if ( faceIdToBoolPair.second )
1863 existingFacesMap_It = existingFacesMap.find (_face.first);
1864 if ( existingFacesMap_It != existingFacesMap.end() )
1867 face = mesh.faceList[existingFacesMap_It->second];
1873 face.setId ( mesh.faceList.size() );
1876 for (
UInt kPointId = 0; kPointId < face_Type::S_numPoints; ++kPointId )
1878 face.setPoint ( kPointId, volumeContainerIterator->point ( volumeShape.faceToPoint ( jFaceLocalId, kPointId ) ) );
1880 face.firstAdjacentElementIdentity() = volumeId;
1881 face.firstAdjacentElementPosition() = jFaceLocalId;
1885 face.setMarkerID (face.nullMarkerID() );
1887 face.setBoundary (
false);
1890 mesh.setFace (face, face.localId() );
1892 existingFacesMap.insert ( std::make_pair (_face.first, face.localId() ) );
1896 mesh.addFace ( face);
1898 existingFacesMap.insert ( std::make_pair (_face.first, mesh.lastFace().localId() ) );
1903 if ( faceIdToBoolPair.first > numBoundaryFaces )
1905 existingFacesMap_It = existingFacesMap.find (_face.first);
1906 mesh.faceList ( existingFacesMap_It->second).secondAdjacentElementIdentity() = volumeId;
1907 mesh.faceList ( existingFacesMap_It->second).secondAdjacentElementPosition() = jFaceLocalId;
1912 mesh.setLinkSwitch ( std::string (
"HAS_ALL_FACETS" ) );
1955 template <
typename MeshType>
1957 std::ostream& logStream,
1958 std::ostream& errorStream,
1959 UInt& numBoundaryEdgesFound,
1960 UInt& numInternalEdgesFound,
1961 bool buildBoundaryEdges =
true,
1962 bool buildInternalEdges =
false,
1963 bool verbose =
false,
1966 verbose = verbose && ( mesh.comm()->MyPID() == 0 );
1967 typedef typename MeshType::volume_Type volume_Type;
1968 typedef typename MeshType::elementShape_Type volumeShape_Type;
1969 typedef typename MeshType::edge_Type edge_Type;
1970 typedef typename MeshType::facetShape_Type faceShape_Type;
1971 typedef typename MeshType::edges_Type::iterator Edges_Iterator;
1972 typename MeshType::face_Type* facePtr;
1975 std::map<BareEdge, ID> existingEdges;
1976 typedef std::map<BareEdge, ID>::iterator ExistingEdges_Iterator;
1977 ExistingEdges_Iterator existingEdges_It;
1978 bool edgeExists (
false);
1982 std::pair<
ID,
ID> faceIdToLocalEdgeIdPair;
1983 ID jEdgeLocalId, newEdgeId;
1987 bool externalContainerIsProvided (
false );
1990 if ( (externalContainerIsProvided = ( externalEdgeContainer != 0 ) ) )
1992 temporaryEdgeContainer = externalEdgeContainer;
1993 numBoundaryEdgesFound = temporaryEdgeContainer->size();
1998 numBoundaryEdgesFound = findBoundaryEdges ( mesh, *temporaryEdgeContainer );
2001 numInternalEdgesFound = findInternalEdges ( mesh, *temporaryEdgeContainer, edgeContainer );
2006 for (Edges_Iterator it = mesh.edgeList.begin(); it < mesh.edgeList.end(); ++it)
2008 point1Id = it->point (0).localId();
2009 point2Id = it->point (1).localId();
2010 existingEdges.insert (std::make_pair ( makeBareEdge ( point1Id, point2Id ).first, it->localId() ) );
2014 if ( !buildBoundaryEdges && buildInternalEdges )
2016 if ( mesh.storedEdges() < numBoundaryEdgesFound )
2018 errorStream <<
"ERROR in buildEdges(): mesh does not contain boundary edges" << std::endl;
2019 errorStream <<
" I need to set buildBoundaryEdges=true" << std::endl;
2020 errorStream <<
" ABORT CONDITION" << std::endl;
2023 else if ( mesh.storedEdges() > numBoundaryEdgesFound )
2025 mesh.edgeList.resize ( numBoundaryEdgesFound );
2028 mesh.setNumBEdges ( numBoundaryEdgesFound );
2029 mesh.setNumEdges ( numBoundaryEdgesFound + numInternalEdgesFound );
2031 if ( buildBoundaryEdges && ! buildInternalEdges )
2033 mesh.setMaxNumEdges ( numBoundaryEdgesFound,
false );
2035 if ( buildInternalEdges )
2037 mesh.setMaxNumEdges ( numBoundaryEdgesFound + numInternalEdgesFound,
true );
2042 errorStream <<
"Building edges" << std::endl;
2047 if ( buildBoundaryEdges )
2052 logStream <<
"**** Marker Flags for Newly Created Boundary Edges ***" 2054 logStream <<
"Edgeid->marker" << std::endl;
2058 for ( temporaryEdgeContainer_Type::iterator edgeContainerIterator = temporaryEdgeContainer->begin();
2059 edgeContainerIterator != temporaryEdgeContainer->end(); ++edgeContainerIterator )
2061 faceIdToLocalEdgeIdPair = edgeContainerIterator->second;
2062 faceId = faceIdToLocalEdgeIdPair.first;
2063 facePtr = &mesh.face ( faceId );
2064 jEdgeLocalId = faceIdToLocalEdgeIdPair.second;
2065 point1Id = facePtr->point ( faceShape_Type::edgeToPoint ( jEdgeLocalId, 0) ).localId();
2066 point2Id = facePtr->point ( faceShape_Type::edgeToPoint ( jEdgeLocalId, 1) ).localId();
2067 existingEdges_It = existingEdges.find ( ( makeBareEdge ( point1Id, point2Id ) ).first);
2068 if (existingEdges_It != existingEdges.end() )
2070 edge = mesh.edge (existingEdges_It->second);
2077 edge.setId ( mesh.edgeList.size() );
2080 for ( UInt kPointId = 0; kPointId < edge_Type::S_numPoints; ++kPointId )
2082 edge.setPoint ( kPointId, facePtr->point ( faceShape_Type::edgeToPoint ( jEdgeLocalId, kPointId ) ) );
2086 if ( edge.isMarkerUnset() )
2088 inheritPointsWeakerMarker ( edge );
2090 edge.setBoundary (
true);
2093 newEdgeId = edge.localId();
2094 mesh.setEdge (edge, newEdgeId);
2098 newEdgeId = mesh.addEdge ( edge).localId();
2103 if ( newEdgeId % 6 == 0 )
2105 logStream << std::endl;
2107 logStream << newEdgeId <<
" -> " << edge.markerID();
2113 logStream << std::endl <<
" ***** END OF LIST OF BOUNDARY EDGES ****" 2116 mesh.setLinkSwitch ( std::string (
"HAS_BOUNDARY_RIDGES" ) );
2119 if ( !externalContainerIsProvided )
2121 delete temporaryEdgeContainer;
2124 if ( !buildInternalEdges )
2126 mesh.unsetLinkSwitch ( std::string (
"HAS_ALL_RIDGES" ) );
2134 volume_Type* volumePtr;
2135 for ( temporaryEdgeContainer_Type::iterator edgeContainerIterator = edgeContainer.begin();
2136 edgeContainerIterator != edgeContainer.end(); ++edgeContainerIterator )
2138 faceIdToLocalEdgeIdPair = edgeContainerIterator->second;
2139 faceId = faceIdToLocalEdgeIdPair.first;
2140 volumePtr = &mesh.volume ( faceId );
2141 jEdgeLocalId = faceIdToLocalEdgeIdPair.second;
2142 point1Id = volumePtr->point ( volumeShape_Type::edgeToPoint ( jEdgeLocalId, 0) ).localId();
2143 point2Id = volumePtr->point ( volumeShape_Type::edgeToPoint ( jEdgeLocalId, 1) ).localId();
2144 existingEdges_It = existingEdges.find ( ( makeBareEdge ( point1Id, point2Id ) ).first);
2145 if (existingEdges_It != existingEdges.end() )
2147 edge = mesh.edge (existingEdges_It->second);
2154 edge.setId ( mesh.edgeList.size() );
2157 for ( UInt kPointId = 0; kPointId < edge_Type::S_numPoints; ++kPointId )
2159 edge.setPoint ( kPointId, volumePtr->point ( volumeShape_Type::edgeToPoint ( jEdgeLocalId, kPointId ) ) );
2162 edge.setMarkerID (edge.nullMarkerID() );
2163 edge.setBoundary (
false);
2166 mesh.setEdge (edge, edge.localId() );
2170 mesh.addEdge ( edge);
2174 mesh.setLinkSwitch ( std::string (
"HAS_ALL_RIDGES" ) );
2195 template <
typename MeshType>
2199 bool verbose ( mesh.comm()->MyPID() == 0 );
2201 typedef typename MeshType::elementShape_Type GeoShape;
2202 typedef typename MeshType::facetShape_Type GeoBShape;
2203 ASSERT_PRE ( GeoShape::S_numPoints > 4,
"p2MeshFromP1Data ERROR: we need a P2 mesh" );
2205 if ( verbose ) logStream <<
"Building P2 mesh points and connectivities from P1 data" 2209 typename MeshType::point_Type* pointPtr = 0;
2210 typename MeshType::edge_Type* edgePtr = 0;
2211 typename MeshType::volume_Type* elementPtr = 0;
2212 typename MeshType::face_Type* facePtr = 0;
2215 std::pair<
UInt,
bool> edgeIdToBoolPair;
2216 UInt point1Id, point2Id, edgeId;
2217 std::pair<
BareEdge,
bool> bareEdgeToBoolPair;
2218 typename MeshType::elementShape_Type elementShape;
2222 logStream <<
"Processing " << mesh.storedEdges() <<
" P1 Edges" << std::endl;
2224 UInt numBoundaryEdges = mesh.numBEdges();
2225 for (
UInt jEdgeId = 0; jEdgeId < mesh.storedEdges(); ++jEdgeId )
2227 edgePtr = & mesh.edge ( jEdgeId );
2228 point1Id = ( edgePtr->point ( 0 ) ).localId();
2229 point2Id = ( edgePtr->point ( 1 ) ).localId();
2230 pointPtr = & mesh.addPoint ( jEdgeId < numBoundaryEdges,
false );
2231 pointPtr->setId ( mesh.pointList.size() - 1 );
2232 pointPtr->x() = ( ( edgePtr->point ( 0 ) ).x() +
2233 ( edgePtr->point ( 1 ) ).x() ) * .5;
2234 pointPtr->y() = ( ( edgePtr->point ( 0 ) ).y() +
2235 ( edgePtr->point ( 1 ) ).y() ) * .5;
2236 pointPtr->z() = ( ( edgePtr->point ( 0 ) ).z() +
2237 ( edgePtr->point ( 1 ) ).z() ) * .5;
2244 if ( edgePtr->isMarkerUnset() )
2246 inheritPointsWeakerMarker ( *edgePtr );
2248 pointPtr->setMarkerID ( edgePtr->markerID() );
2250 edgePtr->setPoint ( 3, pointPtr );
2251 bareEdgeToBoolPair = makeBareEdge ( point1Id, point2Id );
2252 edgeIdToBoolPair = bareEdgeHandler.addIfNotThere ( bareEdgeToBoolPair.first, pointPtr->localId() );
2256 if ( GeoShape::S_nDimensions == 3 )
2258 UInt numBoundaryFaces = mesh.numBFaces();
2260 if ( verbose ) logStream <<
"Processing " << mesh.storedFaces() <<
" Face Edges" 2262 for (
UInt kFaceId = 0; kFaceId < mesh.storedFaces(); ++kFaceId )
2264 facePtr = &mesh.face ( kFaceId );
2265 for (
UInt jEdgeLocalId = 0; jEdgeLocalId < mesh.numLocalEdgesOfFace(); jEdgeLocalId++ )
2267 point1Id = GeoBShape::edgeToPoint ( jEdgeLocalId, 0 );
2268 point2Id = GeoBShape::edgeToPoint ( jEdgeLocalId, 1 );
2269 point1Id = ( facePtr->point ( point1Id ) ).localId();
2270 point2Id = ( facePtr->point ( point2Id ) ).localId();
2271 bareEdgeToBoolPair = makeBareEdge ( point1Id, point2Id );
2272 edgeId = bareEdgeHandler.id ( bareEdgeToBoolPair.first );
2275 pointPtr = &mesh.point ( edgeId );
2280 pointPtr = &mesh.addPoint ( kFaceId < numBoundaryFaces,
false );
2281 edgeIdToBoolPair = bareEdgeHandler.addIfNotThere ( bareEdgeToBoolPair.first, pointPtr->localId() );
2282 pointPtr->setId ( mesh.pointList.size() - 1 );
2283 pointPtr->x() = ( mesh.point ( point1Id ).x() +
2284 mesh.point ( point2Id ).x() ) * .5;
2285 pointPtr->y() = ( mesh.point ( point1Id ).y() +
2286 mesh.point ( point2Id ).y() ) * .5;
2287 pointPtr->z() = ( mesh.point ( point1Id ).z() +
2288 mesh.point ( point2Id ).z() ) * .5;
2291 pointPtr->setMarkerID ( facePtr->markerID() );
2293 facePtr->setPoint ( GeoBShape::S_numVertices + jEdgeLocalId, pointPtr );
2298 if ( verbose ) logStream <<
"Processing " << mesh.numElements() <<
" Mesh Elements" 2300 UInt nev = GeoShape::S_numVertices;
2301 for (
UInt kElementId = 0; kElementId < mesh.numElements(); ++kElementId )
2303 elementPtr = &mesh.element ( kElementId );
2304 for (
UInt jEdgeLocalId = 0; jEdgeLocalId < mesh.numLocalEdges(); jEdgeLocalId++ )
2306 point1Id = elementShape.edgeToPoint ( jEdgeLocalId, 0 );
2307 point2Id = elementShape.edgeToPoint ( jEdgeLocalId, 1 );
2308 point1Id = ( elementPtr->point ( point1Id ) ).localId();
2309 point2Id = ( elementPtr->point ( point2Id ) ).localId();
2310 bareEdgeToBoolPair = makeBareEdge ( point1Id, point2Id );
2311 edgeId = bareEdgeHandler.id ( bareEdgeToBoolPair.first );
2314 pointPtr = &mesh.point ( edgeId );
2319 pointPtr = &mesh.addPoint (
false,
false );
2320 edgeIdToBoolPair = bareEdgeHandler.addIfNotThere ( bareEdgeToBoolPair.first, pointPtr->localId() );
2321 pointPtr->setId ( mesh.pointList.size() - 1 );
2322 pointPtr->x() = ( mesh.point ( point1Id ).x() +
2323 mesh.point ( point2Id ).x() ) * .5;
2324 pointPtr->y() = ( mesh.point ( point1Id ).y() +
2325 mesh.point ( point2Id ).y() ) * .5;
2326 pointPtr->z() = ( mesh.point ( point1Id ).z() +
2327 mesh.point ( point2Id ).z() ) * .5;
2328 pointPtr->setMarkerID ( edgePtr->markerID() );
2330 elementPtr->setPoint ( nev + jEdgeLocalId, pointPtr );
2334 if ( verbose ) logStream <<
" ******* Done Construction of P2 Mesh *******" 2335 << std::endl << std::endl;
2385 template <
typename REGIONMESH,
typename RMTYPE =
typename REGIONMESH::markerCommon_Type >
2410 template <
typename VECTOR>
2425 template <
typename VECTOR>
2426 void transformMesh (
const VECTOR& scale,
const VECTOR& rotate,
const VECTOR& translate );
2435 template <
typename function>
2444 return ! (
this->M_pointList.empty() );
2456 this->M_pointList.clear();
2510 template<
typename REGIONMESH>
2516 template <
typename REGIONMESH,
typename RMTYPE >
2522 template <
typename VECTOR>
2526 if ( disp.mapType() ==
Unique )
2528 #ifdef HAVE_LIFEV_DEBUG 2529 std::cerr <<
"Info: moveMesh() requires a Repeated vector, a copy of the passed Unique vector will be created.\n" 2530 <<
"To optimize your code, you should pass a repeated vector to avoid the conversion." << std::endl;
2532 this->moveMesh ( VECTOR ( disp,
Repeated ), dim );
2536 if ( !
this->hasOldPoint() )
2541 typedef typename REGIONMESH::points_Type points_Type;
2542 points_Type& pointList (
M_mesh.pointList );
2543 for (
UInt i = 0; i <
M_mesh.pointList.size(); ++i )
2547 int globalId = pointList[i].id();
2548 ASSERT ( disp.isGlobalIDPresent ( globalId + dim * j ),
"global ID missing" );
2549 pointList[ i ].coordinate ( j ) =
M_pointList[ i ].coordinate ( j ) + disp[ j * dim + globalId ];
2554 template<
typename REGIONMESH,
typename RMTYPE >
2562 std::copy (
M_mesh.pointList.begin(),
M_mesh.pointList.end(),
2572 template <
typename REGIONMESH,
typename RMTYPE >
2576 ASSERT_BD ( i < M_mesh.pointList.size() );
2580 template <
typename REGIONMESH,
typename RMTYPE >
2589 template <
typename VECTOR>
2593 typename REGIONMESH::points_Type& pointList (
M_mesh.pointList);
2596 boost::numeric::ublas::matrix<Real> R (3, 3), R1 (3, 3), R2 (3, 3), R3 (3, 3), S (3, 3);
2602 R1 (1, 1) = std::cos (rotate[0]);
2603 R1 (1, 2) = -std::sin (rotate[0]);
2605 R1 (2, 1) = std::sin (rotate[0]);
2606 R1 (2, 2) = std::cos (rotate[0]);
2608 R2 (0, 0) = std::cos (rotate[1]);
2610 R2 (0, 2) = std::sin (rotate[1]);
2614 R2 (2, 0) = -std::sin (rotate[1]);
2616 R2 (2, 2) = std::cos (rotate[1]);
2618 R3 (0, 0) = std::cos (rotate[2]);
2619 R3 (0, 1) = -std::sin (rotate[2]);
2621 R3 (1, 0) = std::sin (rotate[2]);
2622 R3 (1, 1) = std::cos (rotate[2]);
2628 S (0, 0) = scale[0];
2632 S (1, 1) = scale[1];
2636 S (2, 2) = scale[2];
2645 boost::numeric::ublas::vector<Real> P (3), T (3);
2646 T (0) = translate[0];
2647 T (1) = translate[1];
2648 T (2) = translate[2];
2651 for (
UInt i (0); i < pointList.size(); ++i )
2655 P ( 0 ) = pointList[ i ].coordinate ( 0 );
2656 P ( 1 ) = pointList[ i ].coordinate ( 1 );
2657 P ( 2 ) = pointList[ i ].coordinate ( 2 );
2659 P = T + prod ( R, P );
2661 pointList[ i ].coordinate ( 0 ) = P ( 0 );
2662 pointList[ i ].coordinate ( 1 ) = P ( 1 );
2663 pointList[ i ].coordinate ( 2 ) = P ( 2 );
2668 template <
typename function>
2672 typename REGIONMESH::points_Type& pointList (
M_mesh.pointList);
2674 for (
UInt i = 0; i < pointList.size(); ++i )
2676 typename REGIONMESH::point_Type& p = pointList[ i ];
2677 meshMapping (p.coordinate (0), p.coordinate (1), p.coordinate (2) );
2681 template <
typename REGIONMESH>
2684 const Real bignumber = std::numeric_limits<
Real>::max();
2685 Real MaxH (0), MinH (bignumber), MeanH (0);
2686 Real deltaX (0), deltaY (0), deltaZ (0), sum (0);
2687 typedef typename REGIONMESH::edges_Type edges_Type;
2688 edges_Type
const& edgeList (mesh.edgeList);
2692 for (
typename edges_Type::const_iterator i = edgeList.begin(); i < edgeList.end() ; ++i )
2694 deltaX = i->point ( 1 ).x() - i->point ( 0 ).x();
2695 deltaY = i->point ( 1 ).y() - i->point ( 0 ).y();
2696 deltaZ = i->point ( 1 ).z() - i->point ( 0 ).z();
2701 sum = deltaX + deltaY + deltaZ;
2702 MaxH = std::max ( MaxH, sum);
2703 MinH = std::min ( MinH, sum);
2708 out
.minH = std::sqrt ( MinH );
2709 out
.meanH = std::sqrt ( MeanH /
static_cast<
Real> ( edgeList.size() ) );
2710 out
.maxH = std::sqrt ( MaxH );
2714 template <
typename RegionMeshType,
typename RegionFunctorType>
2719 typename RegionMeshType::elements_Type& elementList = mesh.elementList ();
2720 const UInt elementListSize = elementList.size();
2723 for (
UInt i = 0; i < elementListSize; ++i )
2728 for (
UInt k = 0; k < RegionMeshType::element_Type::S_numPoints; k++ )
2730 barycentre += elementList[i].point ( k ).coordinates();
2732 barycentre /= RegionMeshType::element_Type::S_numPoints;
2735 elementList[i].setMarkerID ( fun ( barycentre ) );
This is the base class to store basic properties of any mesh entity.
mesh_Type::facetShape_Type faceShape_Type
void fixBoundaryPoints(MeshType &mesh, std::ostream &logStream=std::cout, std::ostream &=std::cerr, bool verbose=true)
It fixes boundary flag on points laying on boundary faces.
UInt findFaces(const MeshType &mesh, temporaryFaceContainer_Type &boundaryFaceContainer, UInt &numInternalFaces, temporaryFaceContainer_Type &internalFaces, bool buildAllFaces=false)
Finds mesh faces.
EnquireBEdge(temporaryEdgeContainer_Type const &boundaryEdgeContainer)
Constructor taking a mesh object and an edge container.
EnquireBFace()
Empty Constructor.
UInt findInternalEdges(const MeshType &mesh, const temporaryEdgeContainer_Type &boundaryEdgeContainer, temporaryEdgeContainer_Type &internalEdgeContainer)
Finds internal edges.
std::map< BareFace, std::pair< ID, ID >, cmpBareItem< BareFace > > temporaryFaceContainer_Type
A locally used structure, not meant for general use.
I use standard constructor/destructors.
virtual ~GetOnes()
Virtual Destructor.
bool checkId(const MeshEntityListType &meshEntityList)
Verifies if a list of mesh entities have the ID properly set.
Functor to check if a Face is on the boundary.
temporaryFaceContainer_Type const * temporaryFaceContainerPtr_Type
int32_type Int
Generic integer data.
UInt testDomainTopology(MeshType const &mesh, UInt &numBoundaryEdges)
GetCoordComponent(Int i)
Constructor taking the component.
bool buildFaces(MeshType &mesh, std::ostream &logStream, std::ostream &errorStream, UInt &numBoundaryFaces, UInt &numInternalFaces, bool buildBoundaryFaces=true, bool buildInternalFaces=false, bool verbose=false, temporaryFaceContainer_Type *externalFaceContainer=0)
Builds faces.
ID markerID_Type
markerID_Type is the type used to store the geometric entity marker IDs
virtual ~EnquireBEdge()
Virtual Destructor.
GetOnes(const GetOnes &)
Copy Constructor.
void updateInverseJacobian(const UInt &iQuadPt)
EnquireBPoint(EnquireBPoint const &enquireBoundaryPoint)
Copy Constructor.
void create(const char *a, bool status=false)
bool testOneSet(flag_Type const &inputFlag, flag_Type const &refFlag)
returns true if at least one flag set in refFlag is set in inputFlag
UInt findBoundaryEdges(const MeshType &mesh, temporaryEdgeContainer_Type &boundaryEdgeContainer)
Finds boundary edges.
EnquireBPoint(mesh_Type &mesh)
Constructor taking a mesh object.
void setBoundaryEdgesMarker(MeshType &mesh, std::ostream &logStream=std::cout, std::ostream &=std::cerr, bool verbose=true)
Sets the marker id for all boundary edges by inheriting them from boundary points.
This functor is used to do some geometry checks.
EnquireBFace(temporaryFaceContainer_Type const &boundaryFaceContainer)
Constructor taking a mesh object and a face Entity.
mesh_Type::face_Type face_Type
void assignRegionMarkerID(RegionMeshType &mesh, const RegionFunctorType &fun)
const flag_Type PHYSICAL_BOUNDARY(0x01)
bool operator()(const MeshEntity &meshEntity) const
The function call operator.
meshSize computeSize(const REGIONMESH &)
Computes mesh sizes.
bool boundary() const
Tells if it is on the boundary.
void operator()(Real const &x, Real const &y, Real const &z, Real ret[3]) const
The function call operator.
void setBoundaryFacesMarker(MeshType &mesh, std::ostream &logStream=std::cout, std::ostream &=std::cerr, bool verbose=true)
Sets the marker ID for all boundary faces by inheriting them from boundary points.
bool buildEdges(MeshType &mesh, std::ostream &logStream, std::ostream &errorStream, UInt &numBoundaryEdgesFound, UInt &numInternalEdgesFound, bool buildBoundaryEdges=true, bool buildInternalEdges=false, bool verbose=false, temporaryEdgeContainer_Type *externalEdgeContainer=0)
It builds edges.
markerID_Type inheritPointsWeakerMarker(MeshElementMarkedType &geoElement)
Sets the marker ID of a MeshElementMarked of dimension greater one.
double Real
Generic real data.
UInt findBoundaryFaces(const MeshType &mesh, temporaryFaceContainer_Type &boundaryFaceContainer, UInt &numInternalFaces)
Finds boundary faces.
flag related free functions and functors
temporaryEdgeContainerPtr_Type boundaryEdgeContainerPtr
bool checkIsMarkerSet(const MeshEntityListType &meshEntityList)
Check whether all markers of a the geometry entities stored in a list are set.
void setBoundaryPointsMarker(MeshType &mesh, std::ostream &logStream=std::cout, std::ostream &=std::cerr, bool verbose=false)
It sets the marker ID for Points, by inheriting it from facets.
bool rearrangeFaces(MeshType &mesh, std::ostream &logStream, std::ostream &errorStream, Switch &sw, UInt &numFaces, UInt &numBoundaryFaces, bool verbose=false, temporaryFaceContainer_Type *externalFaceContainer=0)
It rearranges the faces stored in the mesh.
container_Type::const_iterator containerConstIterator_Type
temporaryEdgeContainer_Type const * temporaryEdgeContainerPtr_Type
available bit-flags for different geometric properties
EnquireBEdge()
Empty Constructor.
const UInt nDimensions(NDIM)
void p2MeshFromP1Data(MeshType &mesh, std::ostream &logStream=std::cout)
It builds a P2 mesh from P1 data.
GetCoordComponent(const GetCoordComponent &getCoordComponent)
Copy constructor.
temporaryFaceContainerPtr_Type boundaryFaceContainerPtr
virtual ~EnquireBFace()
Virtual Destructor.
bool fixBoundaryFaces(MeshType &mesh, std::ostream &logStream, std::ostream &errorStream, Switch &sw, UInt &numFaces, UInt &numBoundaryFaces, bool=false, bool verbose=false, temporaryFaceContainer_Type *externalFaceContainer=0)
It fixes boundary faces so that they are consistently numbered with volumes.
VectorSmall< 3 > Vector3D
EnquireBEdge(EnquireBEdge const &enquireBoundaryEdge)
Copy Constructor.
bool operator()(const face_Type &face) const
The function call operator.
mesh_Type const * meshPtr_Type
GetOnes()
Empty Constructor.
Assert & error(const char *strMsg=0)
bool operator()(const edge_Type &edge) const
The function call operator.
virtual ~GetCoordComponent()
Virtual Destructor.
markerID_Type inheritPointsStrongerMarker(MeshElementMarkedType &geoElement)
GetCoordComponent()
Empty Constructor.
It holds statistics on mesh size.
void operator()(Real const &x, Real const &y, Real const &z, Real ret[3]) const
The function call operator.
virtual ~EnquireBPoint()
Virtual Destructor.
std::map< BareEdge, std::pair< ID, ID >, cmpBareItem< BareEdge > > temporaryEdgeContainer_Type
A locally used structure, not meant for general use.
EnquireBPoint()
Empty Constructor.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
void fixId(MeshEntityListType &meshEntityList)
Fixes a a list of mesh entities so that the ID is properly set.
mesh_Type const * meshPtr_Type
void setBoundaryPointsCounters(MeshType &mesh)
Fixes boundary points counter It fix the boundary points counter by counting how many points have the...
mesh_Type::edge_Type edge_Type