41 #ifndef _IMPORTERMESH3D_HH_ 42 #define _IMPORTERMESH3D_HH_ 1
45 #include <boost/lambda/bind.hpp> 46 #include <boost/lambda/if.hpp> 47 #include <boost/lambda/lambda.hpp> 50 #include <lifev/core/LifeV.hpp> 52 #include <lifev/core/util/StringUtility.hpp> 54 #include <lifev/core/mesh/MeshElementBare.hpp> 56 #include <lifev/core/mesh/MeshChecks.hpp> 57 #include <lifev/core/mesh/InternalEntitySelector.hpp> 58 #include <lifev/core/mesh/BareMesh.hpp> 59 #include <lifev/core/mesh/RegionMesh.hpp> 107 UInt& numberVertices,
108 UInt& numberBoundaryVertices,
109 UInt& numberBoundaryFaces,
110 UInt& numberBoundaryEdges,
111 UInt& numberVolumes );
124 template <
typename GeoShape,
typename MC>
126 readMppFile ( RegionMesh<GeoShape, MC>& mesh,
127 const std::string& fileName,
129 bool verbose =
false )
131 typedef RegionMesh<GeoShape, MC> mesh_Type;
133 const int idOffset = 1;
143 UInt numberVertices ( 0 ), numberBoundaryVertices ( 0 ),
144 numberFaces ( 0 ), numberBoundaryFaces ( 0 ),
145 numberPoints ( 0 ), numberBoundaryPoints ( 0 ),
146 numberEdges ( 0 ), numberBoundaryEdges ( 0 );
147 UInt numberVolumes ( 0 );
150 std::stringstream discardedLog;
152 std::ostream& oStr = verbose ? std::cout : discardedLog;
159 std::ifstream hstream ( fileName.c_str() );
161 if ( hstream.fail() )
163 std::cerr <<
" Error in readMpp: File " << fileName
164 <<
" not found or locked" << std::endl;
168 std::cout <<
"Reading mesh++ file" << std::endl;
171 numberBoundaryFaces
, numberBoundaryEdges
, numberVolumes
) )
173 std::cerr <<
" Error While reading mesh++ file headers" << std::endl;
179 UInt numberStoredEdges = numberBoundaryEdges;
182 std::ifstream myStream ( fileName.c_str() );
184 if ( myStream.fail() )
186 std::cerr <<
" Error in readMpp: file " << fileName
187 <<
" not found or locked" << std::endl;
192 numberFaces = 2 * numberVolumes + ( numberBoundaryFaces / 2 );
193 numberEdges = numberVolumes + numberVertices +
194 ( 3 * numberBoundaryFaces - 2 * numberBoundaryVertices ) / 4;
197 if ( GeoShape::S_numPoints > 4 )
199 std::cout <<
"Quadratic Tetra Mesh (from Linear geometry)" 201 numberPoints = numberVertices + numberEdges;
202 numberBoundaryPoints = numberBoundaryVertices + numberBoundaryEdges;
207 std::cout <<
"Linear Tetra Mesh" << std::endl;
208 numberPoints = numberVertices;
209 numberBoundaryPoints = numberBoundaryVertices;
212 std::cout <<
"Number of Vertices = " << std::setw ( 10 ) << numberVertices << std::endl
213 <<
"Number of Boundary Vertices = " << std::setw ( 10 ) << numberBoundaryVertices << std::endl;
214 oStr <<
"Number of Faces = " << std::setw ( 10 ) << numberFaces << std::endl
215 <<
"Number of Boundary Faces = " << std::setw ( 10 ) << numberBoundaryFaces << std::endl
216 <<
"Number of Edges = " << std::setw ( 10 ) << numberEdges << std::endl
217 <<
"Number of Boundary Edges = " << std::setw ( 10 ) << numberBoundaryEdges << std::endl;
218 std::cout <<
"Number of Points = " << std::setw ( 10 ) << numberPoints << std::endl
219 <<
"Number of Boundary Points = " << std::setw ( 10 ) << numberBoundaryPoints << std::endl
220 <<
"Number of Volumes = " << std::setw ( 10 ) << numberVolumes << std::endl;
225 mesh.setMaxNumPoints ( numberPoints,
true );
226 mesh.setMaxNumGlobalPoints ( numberPoints );
227 mesh.setNumBPoints ( numberBoundaryPoints );
228 mesh.setNumVertices ( numberVertices );
229 mesh.setNumGlobalVertices ( numberVertices );
230 mesh.setNumBVertices ( numberBoundaryVertices );
233 mesh.setMaxNumEdges ( numberEdges );
234 mesh.setMaxNumGlobalEdges ( numberEdges );
235 mesh.setNumEdges ( numberEdges );
236 mesh.setNumBEdges ( numberBoundaryEdges );
239 mesh.setMaxNumFaces ( numberBoundaryFaces );
240 mesh.setMaxNumGlobalFaces ( numberBoundaryFaces );
241 mesh.setNumFaces ( numberFaces );
242 mesh.setNumBFaces ( numberBoundaryFaces );
244 mesh.setMaxNumVolumes ( numberVolumes,
true );
245 mesh.setMaxNumGlobalVolumes ( numberVolumes );
247 mesh.setMarkerID ( regionFlag );
250 typename mesh_Type::point_Type* pointerPoint = 0;
251 typename mesh_Type::edge_Type* pointerEdge = 0;
252 typename mesh_Type::face_Type* pointerFace = 0;
253 typename mesh_Type::volume_Type* pointerVolume = 0;
261 while ( nextGoodLine ( myStream, line ).good() )
263 if ( line.find (
"odes" ) != std::string::npos )
266 std::string node_s = line.substr ( line.find_last_of (
":" ) + 1 );
269 for ( i = 0; i < numberVertices; i++ )
272 myStream >> x >> y >> z >> ity >> ibc;
275 myStream >> x >> y >> z >> ity >> ity_id;
284 pointerPoint = &mesh.addPoint (
true,
true );
285 pointerPoint->setId ( count );
290 pointerPoint->setMarkerID ( markerID_Type ( ibc ) );
294 pointerPoint = &mesh.addPoint (
false,
true );
295 pointerPoint->setId ( mesh.pointList.size() - 1 );
298 pointerPoint->x() = x;
299 pointerPoint->y() = y;
300 pointerPoint->z() = z;
301 pointerPoint->setMarkerID ( markerID_Type ( ibc ) );
304 oStr <<
"Vertices Read " << std::endl;
307 if ( count != numberBoundaryVertices )
309 std::cerr <<
"NumB points inconsistent!" << std::endl;
312 if ( line.find (
"iangular" ) != std::string::npos )
314 oStr <<
"Reading Bfaces " << std::endl;
315 std::string node_s = line.substr ( line.find_last_of (
":" ) + 1 );
317 for ( i = 0; i < numberBoundaryFaces; i++ )
321 myStream >> p1 >> p2 >> p3 >> ity >> ibc;
324 myStream >> p1 >> p2 >> p3 >> ity >> ity_id >> ibc;
330 pointerFace = & ( mesh.addFace (
true ) );
332 pointerFace->setMarkerID ( markerID_Type ( ibc ) );
333 pointerFace->setId ( i );
334 pointerFace->setPoint ( 0, mesh.point ( p1 ) );
335 pointerFace->setPoint ( 1, mesh.point ( p2 ) );
336 pointerFace->setPoint ( 2, mesh.point ( p3 ) );
339 oStr <<
"Boundary faces read " << std::endl;
343 if ( line.find (
"Sides" ) != std::string::npos )
345 oStr <<
"Reading boundary edges " << std::endl;
346 std::string node_s = line.substr ( line.find_last_of (
":" ) + 1 );
349 for ( i = 0; i < numberStoredEdges; i++ )
352 myStream >> p1 >> p2 >> ity >> ibc;
354 myStream >> p1 >> p2 >> ity >> ity_id >> ibc;
359 pointerEdge = &mesh.addEdge (
true );
360 pointerEdge->setMarkerID ( markerID_Type ( ibc ) );
361 pointerEdge->setId ( i );
362 pointerEdge->setPoint ( 0, mesh.point ( p1 ) );
363 pointerEdge->setPoint ( 1, mesh.point ( p2 ) );
366 oStr <<
"Boundary edges read " << std::endl;
372 if ( line.find (
"etrahedral" ) != std::string::npos )
374 oStr <<
"Reading volumes " << std::endl;
375 std::string node_s = line.substr ( line.find_last_of (
":" ) + 1 );
377 for ( i = 0; i < numberVolumes; i++ )
379 myStream >> p1 >> p2 >> p3 >> p4;
384 pointerVolume = &mesh.addVolume();
385 pointerVolume->setId ( i );
386 pointerVolume->setPoint ( 0, mesh.point ( p1 ) );
387 pointerVolume->setPoint ( 1, mesh.point ( p2 ) );
388 pointerVolume->setPoint ( 2, mesh.point ( p3 ) );
389 pointerVolume->setPoint ( 3, mesh.point ( p4 ) );
393 oStr << count <<
" Volume elements read" << std::endl;
399 if ( GeoShape::S_numPoints > 4 )
412 if ( !checkMesh3D ( mesh, sw,
true, verbose, oStr, std::cerr, oStr ) )
418 getVolumeFromFaces ( mesh, vols, oStr );
420 oStr <<
"Volume enclosed by the mesh computed by integration on boundary faces " << std::endl;
421 oStr <<
"INT(X) INT(Y) INT(Z) <- they should be equal and equal to" << std::endl
422 <<
" the voulume enclosed by the mesh " << std::endl;
423 oStr << vols[ 0 ] <<
" " << vols[ 1 ] <<
" " << vols[ 2 ] << std::endl;
424 oStr <<
"Boundary faces are defining a closed surface if " 425 << testClosedDomain ( mesh, oStr ) << std::endl
426 <<
"is (almost) zero" << std::endl;
448 nextIntINRIAMeshField ( std::string
const& line,
449 std::istream& myStream );
469 readINRIAMeshFileHead ( std::ifstream& myStream,
470 UInt& numberVertices,
471 UInt& numberBoundaryVertices,
472 UInt& numberBoundaryFaces,
473 UInt& numberBoundaryEdges,
475 UInt& numberStoredFaces,
477 InternalEntitySelector iSelect = InternalEntitySelector() );
491 template <
typename GeoShape,
typename MC>
493 readINRIAMeshFile ( RegionMesh<GeoShape, MC>& mesh,
494 std::string
const& fileName,
496 bool verbose =
false,
497 InternalEntitySelector iSelect = InternalEntitySelector() )
499 typedef RegionMesh<GeoShape, MC> mesh_Type;
501 const int idOffset = 1;
510 UInt numberVertices ( 0 ), numberBoundaryVertices ( 0 ),
511 numberFaces ( 0 ), numberBoundaryFaces ( 0 ),
512 numberPoints ( 0 ), numberBoundaryPoints ( 0 ),
513 numberEdges ( 0 ), numberBoundaryEdges ( 0 );
514 UInt numberVolumes ( 0 );
515 UInt numberStoredFaces ( 0 );
516 UInt p1, p2, p3, p4, p5, p6, p7, p8;
518 std::stringstream discardedLog;
520 std::vector<FiveNumbers> faceHelp;
524 typename std::vector<FiveNumbers>::iterator faceHelpIterator;
526 std::ostream& oStr = verbose ? std::cout : discardedLog;
530 std::ifstream hstream ( fileName.c_str() );
534 std::cout <<
"Reading form file " << fileName << std::endl;
537 if ( hstream.fail() )
539 std::cerr <<
" Error in readINRIAMeshFile = file " << fileName
540 <<
" not found or locked" << std::endl;
546 std::cout <<
"Reading INRIA mesh file" << fileName << std::endl;
549 if ( ! readINRIAMeshFileHead ( hstream, numberVertices, numberBoundaryVertices,
550 numberBoundaryFaces, numberBoundaryEdges,
551 numberVolumes, numberStoredFaces, shape, iSelect) )
553 std::cerr <<
" Error while reading INRIA mesh file headers" << std::endl;
557 UInt numberStoredEdges (numberBoundaryEdges);
561 std::ifstream myStream ( fileName.c_str() );
563 if ( myStream.fail() )
565 std::cerr <<
" Error in readINRIAMeshFile = file " << fileName
566 <<
" not found or locked" << std::endl;
573 numberFaces = 2 * numberVolumes + ( numberBoundaryFaces / 2 );
574 Int num1 = numberVertices + numberVolumes;
575 Int num2 = numberBoundaryVertices;
576 Int num3 = numberBoundaryFaces;
578 numberEdges = ( 3 * num3 - 2 * num2 ) / 4 + num1;
588 std::cout <<
"Linear Hexa mesh" << std::endl;
589 numberPoints = numberVertices;
590 numberBoundaryPoints = numberBoundaryVertices;
594 if ( GeoShape::S_numPoints > 4 )
597 std::cout <<
"Quadratic Tetra mesh (from linear geometry)" << std::endl;
598 numberPoints = numberVertices + numberEdges;
621 std::cout <<
"Linear Tetra Mesh" << std::endl;
624 numberPoints = numberVertices;
625 numberBoundaryPoints = numberBoundaryVertices;
626 numberBoundaryEdges = (
Int ( numberBoundaryVertices + numberBoundaryFaces -
Int ( 2 ) )
627 > 0 ? ( numberBoundaryVertices + numberBoundaryFaces - 2 ) : 0 );
633 ERROR_MSG (
"Current version of INRIA Mesh file reader only accepts TETRA and HEXA" );
636 oStr <<
"Number of Vertices = " << std::setw ( 10 ) << numberVertices << std::endl
637 <<
"Number of BVertices = " << std::setw ( 10 ) << numberBoundaryVertices << std::endl
638 <<
"Number of Faces = " << std::setw ( 10 ) << numberFaces << std::endl
639 <<
"Number of Boundary Faces = " << std::setw ( 10 ) << numberBoundaryFaces << std::endl
640 <<
"Number of Stored Faces = " << std::setw ( 10 ) << numberStoredFaces << std::endl
641 <<
"Number of Edges = " << std::setw ( 10 ) << numberEdges << std::endl
642 <<
"Number of Boundary Edges = " << std::setw ( 10 ) << numberBoundaryEdges << std::endl
643 <<
"Number of Stored Edges = " << std::setw ( 10 ) << numberStoredEdges << std::endl
644 <<
"Number of Points = " << std::setw ( 10 ) << numberPoints << std::endl
645 <<
"Number of Boundary Points = " << std::setw ( 10 ) << numberBoundaryPoints << std::endl
646 <<
"Number of Volumes = " << std::setw ( 10 ) << numberVolumes << std::endl;
651 mesh.setMaxNumPoints ( numberPoints,
true );
652 mesh.setMaxNumGlobalPoints ( numberPoints );
653 mesh.setNumBPoints ( numberBoundaryPoints );
654 mesh.setNumVertices ( numberVertices );
655 mesh.setNumGlobalVertices ( numberVertices );
656 mesh.setNumBVertices ( numberBoundaryVertices );
658 mesh.setMaxNumEdges ( numberBoundaryEdges );
659 mesh.setMaxNumGlobalEdges ( numberEdges );
660 mesh.setNumEdges ( numberEdges );
661 mesh.setNumBEdges ( numberBoundaryEdges );
663 mesh.setMaxNumFaces ( numberStoredFaces );
664 mesh.setMaxNumGlobalFaces ( numberBoundaryFaces );
665 mesh.setNumFaces ( numberFaces );
666 mesh.setNumBFaces ( numberBoundaryFaces );
668 mesh.setMaxNumVolumes ( numberVolumes,
true );
669 mesh.setMaxNumGlobalVolumes ( numberVolumes );
671 mesh.setMarkerID ( regionFlag );
673 typedef typename mesh_Type::point_Type point_Type;
674 typedef typename mesh_Type::volume_Type volume_Type;
677 point_Type* pointerPoint = 0;
678 typename mesh_Type::edge_Type* pointerEdge = 0;
679 typename mesh_Type::face_Type* pointerFace = 0;
680 volume_Type* pointerVolume = 0;
688 if ( numberStoredFaces > numberBoundaryFaces )
690 faceHelp.resize ( numberStoredFaces - numberBoundaryFaces );
691 faceHelpIterator = faceHelp.begin();
693 oStr <<
"WARNING: The mesh file (apparently) contains " 694 << numberStoredFaces - numberBoundaryFaces <<
" internal faces" << std::endl;
698 while ( nextGoodLine ( myStream, line ).good() )
700 if ( line.find (
"Vertices" ) != std::string::npos )
702 nextIntINRIAMeshField ( line.substr ( line.find_last_of (
"s" ) + 1 ), myStream );
704 for ( i = 0; i < numberVertices; i++ )
706 myStream >> x >> y >> z >> ibc;
708 if ( !iSelect (markerID_Type (ibc) ) )
712 pointerPoint = &mesh.addPoint (
true,
true );
713 pointerPoint->setMarkerID ( markerID_Type ( ibc ) );
718 pointerPoint = &mesh.addPoint (
false,
true );
721 pointerPoint->setId ( i );
722 pointerPoint->x() = x;
723 pointerPoint->y() = y;
724 pointerPoint->z() = z;
725 pointerPoint->setMarkerID ( markerID_Type ( ibc ) );
728 oStr <<
"Vertices read " << std::endl;
729 oStr <<
"Size of the node storage is " 730 << count*
sizeof ( point_Type ) / 1024. / 1024. << std::endl;
733 if ( count != numberBoundaryVertices )
735 std::cerr <<
"Number boundary points inconsistent!" << std::endl;
739 if ( line.find (
"Triangles" ) != std::string::npos )
741 nextIntINRIAMeshField ( line.substr ( line.find_last_of (
"s" ) + 1 ), myStream );
742 oStr <<
"Reading boundary faces " << std::endl;
744 for ( i = 0; i < numberStoredFaces; i++ )
746 myStream >> p1 >> p2 >> p3 >> ibc;
751 if ( numberStoredFaces > numberBoundaryFaces )
753 if ( mesh.point ( p1 ).boundary() && mesh.point ( p2 ).boundary() &&
754 mesh.point ( p3 ).boundary() )
756 pointerFace = & ( mesh.addFace (
true ) );
757 pointerFace->setId ( i );
758 pointerFace->setMarkerID ( markerID_Type ( ibc ) );
759 pointerFace->setPoint ( 0, mesh.point ( p1 ) );
760 pointerFace->setPoint ( 1, mesh.point ( p2 ) );
761 pointerFace->setPoint ( 2, mesh.point ( p3 ) );
767 faceHelpIterator->i1 = p1;
768 faceHelpIterator->i2 = p2;
769 faceHelpIterator->i3 = p3;
770 faceHelpIterator->ibc = ibc;
779 pointerFace = & ( mesh.addFace (
true ) );
781 pointerFace->setMarkerID ( markerID_Type ( ibc ) );
782 pointerFace->setId ( i );
783 pointerFace->setPoint ( 0, mesh.point ( p1 ) );
784 pointerFace->setPoint ( 1, mesh.point ( p2 ) );
785 pointerFace->setPoint ( 2, mesh.point ( p3 ) );
789 UInt extraFaceCounter = numberBoundaryFaces;
790 for ( faceHelpIterator = faceHelp.begin();
791 faceHelpIterator != faceHelp.end(); ++faceHelpIterator, extraFaceCounter++ )
793 p1 = faceHelpIterator->i1;
794 p2 = faceHelpIterator->i2;
795 p3 = faceHelpIterator->i3;
796 ibc = faceHelpIterator->ibc;
797 pointerFace = & ( mesh.addFace (
false ) );
798 pointerFace->setMarkerID ( markerID_Type ( ibc ) );
799 pointerFace->setId ( extraFaceCounter );
800 pointerFace->setPoint ( 0, mesh.point ( p1 ) );
801 pointerFace->setPoint ( 1, mesh.point ( p2 ) );
802 pointerFace->setPoint ( 2, mesh.point ( p3 ) );
805 oStr <<
"Boundary faces read " << std::endl;
809 if ( line.find (
"Quadrilaterals" ) != std::string::npos )
811 nextIntINRIAMeshField ( line.substr ( line.find_last_of (
"s" ) + 1 ), myStream );
813 oStr <<
"Reading boundary faces " << std::endl;
815 for (UInt i = 0; i < numberBoundaryFaces; i++ )
817 myStream >> p1 >> p2 >> p3 >> p4 >> ibc;
823 if ( numberStoredFaces > numberBoundaryFaces )
825 if ( mesh.point ( p1 ).boundary() && mesh.point ( p2 ).boundary() &&
826 mesh.point ( p3 ).boundary() )
828 pointerFace = & ( mesh.addFace (
true ) );
829 pointerFace->setMarkerID ( markerID_Type ( ibc ) );
830 pointerFace->setId ( i );
831 pointerFace->setPoint ( 0, mesh.point ( p1 ) );
832 pointerFace->setPoint ( 1, mesh.point ( p2 ) );
833 pointerFace->setPoint ( 2, mesh.point ( p3 ) );
834 pointerFace->setPoint ( 3, mesh.point ( p4 ) );
840 faceHelpIterator->i1 = p1;
841 faceHelpIterator->i2 = p2;
842 faceHelpIterator->i3 = p3;
843 faceHelpIterator->i4 = p4;
844 faceHelpIterator->ibc = ibc;
852 pointerFace = & ( mesh.addFace (
true ) );
853 pointerFace->setMarkerID ( markerID_Type ( ibc ) );
854 pointerFace->setId ( i );
855 pointerFace->setPoint ( 0, mesh.point ( p1 ) );
856 pointerFace->setPoint ( 1, mesh.point ( p2 ) );
857 pointerFace->setPoint ( 2, mesh.point ( p3 ) );
858 pointerFace->setPoint ( 3, mesh.point ( p4 ) );
862 oStr <<
"Boundary faces read " << std::endl;
864 UInt extraFaceCounter = numberBoundaryFaces;
865 for ( faceHelpIterator = faceHelp.begin();
866 faceHelpIterator != faceHelp.end(); ++faceHelpIterator, extraFaceCounter++ )
868 p1 = faceHelpIterator->i1;
869 p2 = faceHelpIterator->i2;
870 p3 = faceHelpIterator->i3;
871 p4 = faceHelpIterator->i4;
872 ibc = faceHelpIterator->ibc;
873 pointerFace = & ( mesh.addFace (
false ) );
874 pointerFace->setMarkerID ( markerID_Type ( ibc ) );
875 pointerFace->setId ( extraFaceCounter );
876 pointerFace->setPoint ( 0, mesh.point ( p1 ) );
877 pointerFace->setPoint ( 1, mesh.point ( p2 ) );
878 pointerFace->setPoint ( 2, mesh.point ( p3 ) );
879 pointerFace->setPoint ( 3, mesh.point ( p4 ) );
884 if ( line.find (
"Edges" ) != std::string::npos )
886 nextIntINRIAMeshField ( line.substr ( line.find_last_of (
"s" ) + 1 ), myStream );
887 oStr <<
"Reading stored edges " << std::endl;
889 for ( i = 0; i < numberStoredEdges; i++ )
891 myStream >> p1 >> p2 >> ibc;
894 pointerEdge = &mesh.addEdge (
true );
895 pointerEdge->setMarkerID ( markerID_Type ( ibc ) );
896 pointerEdge->setId ( i );
897 pointerEdge->setPoint ( 0, mesh.point ( p1 ) );
898 pointerEdge->setPoint ( 1, mesh.point ( p2 ) );
900 oStr <<
" Stored edges read " << std::endl;
904 if ( line.find (
"Tetrahedra" ) != std::string::npos )
907 nextIntINRIAMeshField ( line.substr ( line.find_last_of (
"a" ) + 1 ), myStream );
908 oStr <<
"Reading volumes " << std::endl;
910 for ( i = 0; i < numberVolumes; i++ )
912 myStream >> p1 >> p2 >> p3 >> p4 >> ibc;
917 pointerVolume = &mesh.addVolume();
918 pointerVolume->setId ( i );
919 pointerVolume->setPoint ( 0, mesh.point ( p1 ) );
920 pointerVolume->setPoint ( 1, mesh.point ( p2 ) );
921 pointerVolume->setPoint ( 2, mesh.point ( p3 ) );
922 pointerVolume->setPoint ( 3, mesh.point ( p4 ) );
923 pointerVolume->setMarkerID ( markerID_Type ( ibc ) );
926 oStr <<
"size of the volume storage is " <<
sizeof ( volume_Type ) * count / 1024. / 1024.
927 <<
" Mo." << std::endl;
928 oStr << count <<
" Volume elements read" << std::endl;
932 if ( line.find (
"Hexahedra" ) != std::string::npos )
935 nextIntINRIAMeshField ( line.substr ( line.find_last_of (
"a" ) + 1 ), myStream );
936 oStr <<
"Reading volumes " << std::endl;
937 for ( i = 0; i < numberVolumes; i++ )
939 myStream >> p1 >> p2 >> p3 >> p4 >> p5 >> p6 >> p7 >> p8 >> ibc;
948 pointerVolume = &mesh.addVolume();
949 pointerVolume->setId ( i );
950 pointerVolume->setPoint ( 0, mesh.point ( p1 ) );
951 pointerVolume->setPoint ( 1, mesh.point ( p2 ) );
952 pointerVolume->setPoint ( 2, mesh.point ( p3 ) );
953 pointerVolume->setPoint ( 3, mesh.point ( p4 ) );
954 pointerVolume->setPoint ( 4, mesh.point ( p5 ) );
955 pointerVolume->setPoint ( 5, mesh.point ( p6 ) );
956 pointerVolume->setPoint ( 6, mesh.point ( p7 ) );
957 pointerVolume->setPoint ( 7, mesh.point ( p8 ) );
958 pointerVolume->setMarkerID ( markerID_Type ( ibc ) );
962 oStr << count <<
" Volume elements read" << std::endl;
972 if ( !checkMesh3D ( mesh, sw,
true, verbose, oStr, std::cerr, oStr ) )
978 if ( shape ==
TETRA && GeoShape::S_numPoints > 4 )
986 getVolumeFromFaces ( mesh, vols, oStr );
988 oStr <<
"Volume enclosed by the mesh computed by integration on boundary faces" << std::endl;
989 oStr <<
"INT(X) INT(Y) INT(Z) <- they should be equal and equal to" << std::endl
990 <<
" the voulume enclosed by the mesh" << std::endl;
991 oStr << vols[ 0 ] <<
" " << vols[ 1 ] <<
" " << vols[ 2 ] << std::endl;
992 oStr <<
"Boundary faces are defining a closed surface if " 993 << testClosedDomain ( mesh, oStr ) << std::endl
994 <<
"is (almost) zero" << std::endl;
1014 template <
typename GeoShape,
typename MC>
1016 readGmshFile ( RegionMesh<GeoShape, MC>& mesh,
1017 const std::string& fileName,
1019 bool verbose =
false )
1021 typedef RegionMesh<GeoShape, MC> mesh_Type;
1023 const int idOffset = 1;
1025 std::ifstream inputFile ( fileName.c_str() );
1027 #ifdef HAVE_LIFEV_DEBUG 1028 debugStream ( 8000 ) <<
"Gmsh reading: " << fileName <<
"\n";
1034 for (
Int ii = 0; ii < 6; ++ii)
1036 inputFile >> buffer;
1037 std::cout <<
"buffer = " << buffer <<
"\n";
1041 inputFile >> numberNodes;
1043 #ifdef HAVE_LIFEV_DEBUG 1044 debugStream ( 8000 ) <<
"Number of nodes = " << numberNodes;
1048 mesh.setMarkerID ( regionFlag );
1051 std::vector<Real> x ( 3 * numberNodes );
1052 std::vector<
bool> isonboundary ( numberNodes );
1053 std::vector<UInt> whichboundary ( numberNodes );
1055 #ifdef HAVE_LIFEV_DEBUG 1056 debugStream ( 8000 ) <<
"Reading " << numberNodes <<
" nodes\n";
1059 std::map<Int, Int> itoii;
1061 for (
UInt i = 0; i < numberNodes; ++i )
1069 itoii[ ni - idOffset] = i;
1071 inputFile >> buffer;
1073 #ifdef HAVE_LIFEV_DEBUG 1074 debugStream ( 8000 ) <<
"buffer = " << buffer <<
"\n";
1077 inputFile >> buffer;
1079 #ifdef HAVE_LIFEV_DEBUG 1080 debugStream ( 8000 ) <<
"buffer = " << buffer <<
"\n";
1083 UInt numberElements;
1084 inputFile >> numberElements;
1086 typename mesh_Type::edge_Type* pointerEdge = 0;
1087 typename mesh_Type::face_Type* pointerFace = 0;
1088 typename mesh_Type::volume_Type* pointerVolume = 0;
1090 #ifdef HAVE_LIFEV_DEBUG 1091 debugStream ( 8000 ) <<
"number of elements: " << numberElements <<
"\n";
1094 std::vector<std::vector<
int> > e ( numberElements );
1095 std::vector<
int> et ( numberElements );
1096 std::vector<
int> etype ( numberElements );
1097 std::vector<
int> gt ( 32 );
1098 gt.assign ( 32, 0 );
1100 for (
UInt i = 0; i < numberElements; ++i )
1104 inputFile >> buffer;
1124 #ifdef HAVE_LIFEV_DEBUG 1125 debugStream ( 8000 ) <<
"Element type unknown " << ne <<
"\n";
1128 ASSERT (
true,
"Elements type unsupported.\n" )
1135 bool ibcSet =
false;
1139 for (
Int iflag = 0; iflag < t; ++iflag )
1155 e[ i ].resize ( np );
1163 e[ i ][ p ] = itoii[ node - idOffset ];
1170 UInt n_volumes = gt[ 4 ];
1171 UInt n_faces_boundary = gt[ 2 ];
1172 UInt n_faces_total = 2 * n_volumes + ( n_faces_boundary / 2 );
1174 mesh.setMaxNumGlobalPoints ( numberNodes );
1176 mesh.setMaxNumEdges ( gt[ 1 ] );
1177 mesh.setNumEdges ( gt[ 1 ] );
1178 mesh.setNumBEdges ( gt[ 1 ] );
1179 mesh.setMaxNumGlobalEdges ( gt[ 1 ] );
1181 #ifdef HAVE_LIFEV_DEBUG 1182 debugStream ( 8000 ) <<
"number of edges= " << gt[ 1 ] <<
"\n";
1186 mesh.setMaxNumFaces ( n_faces_total );
1187 mesh.setNumFaces ( n_faces_total );
1190 mesh.setNumBFaces ( n_faces_boundary );
1191 mesh.setMaxNumGlobalFaces ( n_faces_total );
1193 #ifdef HAVE_LIFEV_DEBUG 1194 debugStream ( 8000 ) <<
"number of faces = " << n_faces_boundary <<
"\n";
1197 mesh.setMaxNumVolumes ( n_volumes,
true );
1198 mesh.setMaxNumGlobalVolumes ( n_volumes );
1200 #ifdef HAVE_LIFEV_DEBUG 1201 debugStream ( 8000 ) <<
"number of volumes = " << n_volumes <<
"\n";
1204 isonboundary.assign ( numberNodes,
false );
1205 whichboundary.assign ( numberNodes, 0 );
1207 for (
UInt i = 0; i < numberElements; ++i )
1209 switch ( etype[ i ] )
1214 isonboundary[ e[ i ][ 0 ] ] =
true;
1215 isonboundary[ e[ i ][ 1 ] ] =
true;
1216 isonboundary[ e[ i ][ 2 ] ] =
true;
1218 whichboundary[ e[ i ][ 0 ] ] = et[ i ];
1219 whichboundary[ e[ i ][ 1 ] ] = et[ i ];
1220 whichboundary[ e[ i ][ 2 ] ] = et[ i ];
1225 typename mesh_Type::point_Type* pointerPoint = 0;
1227 mesh.setMaxNumPoints ( numberNodes,
true );
1228 mesh.setNumVertices ( numberNodes );
1229 mesh.setNumBVertices ( std::count ( isonboundary.begin(), isonboundary.end(),
true ) );
1230 mesh.setNumBPoints ( mesh.numBVertices() );
1232 #ifdef HAVE_LIFEV_DEBUG 1233 debugStream ( 8000 ) <<
"number of points : " << mesh.numPoints() <<
"\n";
1234 debugStream ( 8000 ) <<
"number of boundary points : " << mesh.numBPoints() <<
"\n";
1235 debugStream ( 8000 ) <<
"number of vertices : " << mesh.numVertices() <<
"\n";
1236 debugStream ( 8000 ) <<
"number of boundary vertices : " << mesh.numBVertices() <<
"\n";
1239 for (
UInt i = 0; i < numberNodes; ++i )
1241 pointerPoint = &mesh.addPoint ( isonboundary[ i ],
true );
1242 pointerPoint->setMarkerID ( whichboundary[ i ] );
1243 pointerPoint->setId ( i );
1244 pointerPoint->x() = x[ 3 * i ];
1245 pointerPoint->y() = x[ 3 * i + 1 ];
1246 pointerPoint->z() = x[ 3 * i + 2 ];
1250 for (
UInt i = 0; i < numberElements; ++i )
1252 switch ( etype[ i ] )
1257 pointerEdge = & ( mesh.addEdge (
true ) );
1258 pointerEdge->setMarkerID ( markerID_Type ( et[ i ] ) );
1259 pointerEdge->setId ( i );
1260 pointerEdge->setPoint ( 0, mesh.point ( e[ i ][ 0 ] ) );
1261 pointerEdge->setPoint ( 1, mesh.point ( e[ i ][ 1 ] ) );
1271 pointerFace = & ( mesh.addFace (
true ) );
1272 pointerFace->setMarkerID ( markerID_Type ( et[ i ] ) );
1273 pointerFace->setId ( i );
1274 pointerFace->setPoint ( 0, mesh.point ( e[ i ][ 0 ] ) );
1275 pointerFace->setPoint ( 1, mesh.point ( e[ i ][ 1 ] ) );
1276 pointerFace->setPoint ( 2, mesh.point ( e[ i ][ 2 ] ) );
1284 pointerFace = & ( mesh.addFace (
true ) );
1285 pointerFace->setMarkerID ( markerID_Type ( et[ i ] ) );
1286 pointerFace->setId ( i );
1287 pointerFace->setPoint ( 0, mesh.point ( e[ i ][ 0 ] ) );
1288 pointerFace->setPoint ( 1, mesh.point ( e[ i ][ 1 ] ) );
1289 pointerFace->setPoint ( 2, mesh.point ( e[ i ][ 2 ] ) );
1290 pointerFace->setPoint ( 3, mesh.point ( e[ i ][ 3 ] ) );
1297 pointerVolume = & ( mesh.addVolume() );
1298 pointerVolume->setId ( i );
1299 pointerVolume->setMarkerID ( markerID_Type ( et[ i ] ) );
1300 pointerVolume->setPoint ( 0, mesh.point ( e[ i ][ 0 ] ) );
1301 pointerVolume->setPoint ( 1, mesh.point ( e[ i ][ 1 ] ) );
1302 pointerVolume->setPoint ( 2, mesh.point ( e[ i ][ 2 ] ) );
1303 pointerVolume->setPoint ( 3, mesh.point ( e[ i ][ 3 ] ) );
1310 pointerVolume = & ( mesh.addVolume() );
1312 pointerVolume->setId ( i );
1313 pointerVolume->setMarkerID ( markerID_Type ( et[ i ] ) );
1314 pointerVolume->setPoint ( 0, mesh.point ( e[ i ][ 0 ] ) );
1315 pointerVolume->setPoint ( 1, mesh.point ( e[ i ][ 1 ] ) );
1316 pointerVolume->setPoint ( 2, mesh.point ( e[ i ][ 2 ] ) );
1317 pointerVolume->setPoint ( 3, mesh.point ( e[ i ][ 3 ] ) );
1318 pointerVolume->setPoint ( 4, mesh.point ( e[ i ][ 4 ] ) );
1319 pointerVolume->setPoint ( 5, mesh.point ( e[ i ][ 5 ] ) );
1320 pointerVolume->setPoint ( 6, mesh.point ( e[ i ][ 6 ] ) );
1321 pointerVolume->setPoint ( 7, mesh.point ( e[ i ][ 7 ] ) );
1329 std::stringstream discardedLog;
1330 std::ostream& oStr = verbose ? std::cout : discardedLog;
1332 if ( checkMesh3D (mesh, sw,
true, verbose, oStr, std::cerr, oStr) ==
false )
1334 std::ostringstream ex;
1335 ex <<
"invalid mesh from GSMH";
1337 throw std::logic_error ( ex.str() );
1358 template<
typename GeoShape,
typename MC>
1360 readNetgenMesh (RegionMesh<GeoShape, MC>& mesh,
1361 const std::string& fileName,
1363 bool verbose =
false )
1365 typedef RegionMesh<GeoShape, MC> mesh_Type;
1367 const int idOffset = 1;
1373 UInt numberVertices ( 0 ), numberBoundaryVertices ( 0 ),
1374 numberPoints ( 0 ), numberBoundaryPoints ( 0 ),
1375 numberEdges ( 0 ), numberBoundaryEdges ( 0 ),
1376 numberFaces ( 0 ), numberBoundaryFaces ( 0 ),
1377 numberVolumes ( 0 );
1381 std::vector<UInt> edgePointID, facePointID, volumePointID;
1384 std::vector<
bool> boundaryPoint;
1390 std::vector<markerID_Type> bcnsurf, bcnpoints;
1395 typename MC::pointMarker_Type pointMarker;
1396 typename MC::edgeMarker_Type edgeMarker;
1397 typename MC::faceMarker_Type faceMarker;
1400 std::ifstream fstreamp ( fileName.c_str() );
1401 if (fstreamp.fail() )
1403 std::cerr <<
"Error in readNetgenMesh: File not found or locked" << std::endl;
1407 std::cout <<
"Reading netgen mesh file: " << fileName << std::endl;
1408 getline ( fstreamp, line );
1410 if ( line.find (
"mesh3d" ) == std::string::npos )
1412 std::cerr <<
"Error in readNetgenMesh: mesh file is not in mesh3d format (netgen)" 1425 flag = 1 | 2 | 4 | 8;
1427 while ( getline ( fstreamp, line ) )
1430 if ( line.find (
"points" ) != std::string::npos && flag & 1 )
1432 getline ( fstreamp, line );
1433 std::stringstream parseLine ( line );
1435 parseLine >> numberVertices;
1436 std::cout <<
"[readNetgenMesh] found " << numberVertices <<
" vertices... " << std::flush;
1438 bcnpoints.resize ( numberVertices + 1 );
1439 boundaryPoint.resize ( numberVertices + 1 );
1440 pointCoordinates.resize ( nDimensions * numberVertices );
1442 for ( UInt i = 0; i < numberVertices; i++ )
1447 getline ( fstreamp, line );
1448 std::stringstream parseLine ( line );
1450 parseLine >> x >> y >> z;
1452 pointCoordinates[ i * nDimensions ] = x;
1453 pointCoordinates[ i * nDimensions + 1 ] = y;
1454 pointCoordinates[ i * nDimensions + 2 ] = z;
1455 boundaryPoint [ i ] =
false;
1456 bcnpoints[ i ] = pointMarker.nullMarkerID();
1458 boundaryPoint [ numberVertices ] =
false;
1459 bcnpoints[ numberVertices ] = pointMarker.nullMarkerID();
1463 std::cout <<
"loaded." << std::endl;
1480 std::ifstream fstreame ( fileName.c_str() );
1481 while ( getline ( fstreame, line ) )
1484 if ( line.find (
"edgesegmentsgi2" ) != std::string::npos && flag & 2 )
1486 getline ( fstreame, line );
1487 std::stringstream parseLine ( line );
1489 parseLine >> numberBoundaryEdges;
1491 std::cout <<
"[readNetgenMesh] found " << numberBoundaryEdges <<
" boundary edges... " << std::flush;
1493 edgePointID.resize ( 2 * numberBoundaryEdges );
1495 for ( UInt i = 0; i < numberBoundaryEdges; ++i)
1497 UInt surfnr, t, p1, p2;
1499 getline ( fstreame, line );
1500 std::stringstream parseLine ( line );
1502 parseLine >> surfnr >> t >> p1 >> p2;
1504 edgePointID[ 2 * i ] = p1 - idOffset;
1505 edgePointID[ 2 * i + 1 ] = p2 - idOffset;
1511 std::cout <<
"loaded." << std::endl;
1516 std::ifstream fstreamv ( fileName.c_str() );
1517 while ( getline ( fstreamv, line ) )
1520 if ( line.find (
"volumeelements" ) != std::string::npos && flag & 8 )
1522 getline ( fstreamv, line );
1523 std::stringstream parseLine ( line );
1525 parseLine >> numberVolumes;
1526 std::cout <<
"[readNetgenMesh] found " << numberVolumes <<
" volumes... " << std::flush;
1528 volumePointID.resize ( 4 * numberVolumes );
1530 for ( UInt i = 0; i < numberVolumes; i++ )
1532 UInt matnr, np, p1, p2, p3, p4;
1534 getline ( fstreamv, line );
1535 std::stringstream parseLine ( line );
1537 parseLine >> matnr >> np >> p1 >> p2 >> p3 >> p4;
1539 volumePointID[ 4 * i ] = p1 - idOffset;
1540 volumePointID[ 4 * i + 1 ] = p2 - idOffset;
1541 volumePointID[ 4 * i + 2 ] = p3 - idOffset;
1542 volumePointID[ 4 * i + 3 ] = p4 - idOffset;
1544 ASSERT ( np == 4,
"Error in readNetgenMesh: only tetrahedra elements supported" )
1548 std::cout <<
"loaded." << std::endl;
1555 std::ifstream fstreamf ( fileName.c_str() );
1556 while ( getline ( fstreamf, line ) )
1563 if ( ( line.find (
"surfaceelements") != std::string::npos ) && flag & 4 )
1565 getline ( fstreamf, line );
1566 std::stringstream parseLine ( line );
1568 parseLine >> numberBoundaryFaces;
1570 std::cout <<
"[readNetgenMesh] found " << numberBoundaryFaces
1571 <<
" boundary faces... " << std::flush;
1573 facePointID.resize ( 3 * numberBoundaryFaces );
1574 bcnsurf.resize ( numberBoundaryFaces + 1 );
1575 bcnsurf[ 0 ] = faceMarker.nullMarkerID();
1578 for ( UInt i = 0; i < numberBoundaryFaces; i++ )
1580 UInt surfnr, bcnr, domin, domout, np, p1, p2, p3;
1582 getline ( fstreamf, line );
1590 getline ( fstreamf, line );
1592 std::stringstream parseLine ( line );
1594 parseLine >> surfnr >> bcnr >> domin >> domout >> np >> p1 >> p2 >> p3;
1599 facePointID[ 3 * i ] = p1;
1600 facePointID[ 3 * i + 1 ] = p2;
1601 facePointID[ 3 * i + 2 ] = p3;
1603 bcnsurf[ i + 1 ] = bcnr;
1605 ASSERT ( np == 3,
"Error in readNetgenMesh: only triangular surfaces supported" )
1608 numberBoundaryVertices += boundaryPoint[ p1 ] ? 0 : 1;
1609 numberBoundaryVertices += boundaryPoint[ p2 ] ? 0 : 1;
1610 numberBoundaryVertices += boundaryPoint[ p3 ] ? 0 : 1;
1611 boundaryPoint[ p1 ] = boundaryPoint[ p2 ] = boundaryPoint[ p3 ] =
true;
1619 bcnpoints[ p1 ] = pointMarker.setStrongerMarkerID ( bcnpoints[ p1 ], bcnr );
1620 bcnpoints[ p2 ] = pointMarker.setStrongerMarkerID ( bcnpoints[ p2 ], bcnr );
1621 bcnpoints[ p3 ] = pointMarker.setStrongerMarkerID ( bcnpoints[ p3 ], bcnr );
1632 BareEdge bed = setBareEdge ( p1, p2 );
1634 bihBedges.addIfNotThere ( bed, edgeMarker.nullMarkerID() );
1635 bihBedges[ bed ] = ( ID ) edgeMarker.setStrongerMarkerID ( bihBedges[ bed ], bcnr );
1637 bed = setBareEdge ( p2, p3 );
1638 bihBedges.addIfNotThere ( bed, edgeMarker.nullMarkerID() );
1639 bihBedges[ bed ] = ( ID ) edgeMarker.setStrongerMarkerID ( bihBedges[ bed ], bcnr );
1641 bed = setBareEdge ( p3, p1 );
1642 bihBedges.addIfNotThere ( bed, edgeMarker.nullMarkerID() );
1643 bihBedges[ bed ] = ( ID ) edgeMarker.setStrongerMarkerID ( bihBedges[ bed ], bcnr );
1648 numberBoundaryEdges = bihBedges.howMany();
1649 std::cout <<
"loaded." << std::endl;
1656 ASSERT ( flag == 0,
"[readNetgenMesh] the mesh file does not have all the required sections." )
1658 std::cout <<
"[readNetgenMesh] computed " << numberBoundaryVertices <<
" boundary vertices" << std::endl;
1661 numberFaces = 2 * numberVolumes + ( numberBoundaryFaces / 2 );
1662 numberEdges = numberVolumes + numberVertices + ( 3 * numberBoundaryFaces - 2 * numberBoundaryVertices ) / 4;
1665 if ( GeoShape::S_numPoints > 4 )
1667 std::cout <<
"Quadratic Tetra Mesh (from Linear geometry)" << std::endl;
1668 numberPoints = numberVertices + numberEdges;
1669 numberBoundaryPoints = numberBoundaryVertices + numberBoundaryEdges;
1674 std::cout <<
"Linear Tetra Mesh" << std::endl;
1675 numberPoints = numberVertices;
1676 numberBoundaryPoints = numberBoundaryVertices;
1679 std::stringstream discardedLog;
1680 std::ostream& oStr = verbose ? std::cout : discardedLog;
1683 std::cout <<
"Number of Vertices = " << std::setw ( 10 ) << numberVertices << std::endl
1684 <<
"Number of BVertices = " << std::setw ( 10 ) << numberBoundaryVertices << std::endl;
1685 oStr <<
"Number of Faces = " << std::setw ( 10 ) << numberFaces << std::endl
1686 <<
"Number of Boundary Faces = " << std::setw ( 10 ) << numberBoundaryFaces << std::endl
1687 <<
"Number of Edges = " << std::setw ( 10 ) << numberEdges << std::endl
1688 <<
"Number of Boundary Edges = " << std::setw ( 10 ) << numberBoundaryEdges << std::endl;
1689 std::cout <<
"Number of Points = " << std::setw ( 10 ) << numberPoints << std::endl
1690 <<
"Number of Boundary Points = " << std::setw ( 10 ) << numberBoundaryPoints << std::endl
1691 <<
"Number of Volumes = " << std::setw ( 10 ) << numberVolumes << std::endl;
1696 mesh.setMaxNumPoints ( numberPoints,
true );
1697 mesh.setMaxNumGlobalPoints ( numberPoints );
1698 mesh.setNumBPoints ( numberBoundaryPoints );
1699 mesh.setNumVertices ( numberVertices );
1700 mesh.setNumGlobalVertices ( numberVertices );
1701 mesh.setNumBVertices ( numberBoundaryVertices );
1704 mesh.setMaxNumEdges ( numberBoundaryEdges );
1705 mesh.setMaxNumGlobalEdges ( numberBoundaryEdges );
1706 mesh.setNumEdges ( numberEdges );
1707 mesh.setNumBEdges ( numberBoundaryEdges );
1710 mesh.setMaxNumFaces ( numberBoundaryFaces );
1711 mesh.setMaxNumGlobalFaces ( numberBoundaryFaces );
1712 mesh.setNumFaces ( numberFaces );
1713 mesh.setNumBFaces ( numberBoundaryFaces );
1715 mesh.setMaxNumVolumes ( numberVolumes,
true );
1716 mesh.setMaxNumGlobalVolumes ( numberVolumes );
1718 mesh.setMarkerID ( regionFlag );
1720 typename mesh_Type::point_Type* pointerPoint = 0;
1721 typename mesh_Type::edge_Type* pointerEdge = 0;
1722 typename mesh_Type::face_Type* pointerFace = 0;
1723 typename mesh_Type::volume_Type* pointerVolume = 0;
1728 std::cout <<
"[importerMesh3D] boundaryPoint.size() = " << boundaryPoint.size()
1729 <<
", bcnpoints.size() = " << bcnpoints.size()
1732 for (
UInt i = 0; i < numberVertices; i++ )
1734 pointerPoint = &mesh.addPoint ( boundaryPoint[ i ],
true );
1736 pointerPoint->setId ( i );
1737 pointerPoint->setMarkerID ( bcnpoints[ i ] );
1738 pointerPoint->x() = pointCoordinates[ nDimensions * i ];
1739 pointerPoint->y() = pointCoordinates[ nDimensions * i + 1 ];
1740 pointerPoint->z() = pointCoordinates[ nDimensions * i + 2 ];
1743 std::cout <<
"[importerMesh3D] added points." << std::endl;
1750 MeshElementBareHandler<BareEdge>::const_iterator bedge = bihBedges.begin();
1752 for (
UInt i = 0; i < numberBoundaryEdges; i++ )
1756 pointerEdge = &mesh.addEdge (
true );
1757 pointerEdge->setId ( i );
1758 pointerEdge->setMarkerID ( markerID_Type ( bedge->second ) );
1759 p1 = bedge->first.first;
1760 p2 = bedge->first.second;
1761 pointerEdge->setPoint ( 0, mesh.point ( p1 ) );
1762 pointerEdge->setPoint ( 1, mesh.point ( p2 ) );
1767 std::cout <<
"[importerMesh3D] added edges." << std::endl;
1769 for (
UInt i = 0; i < numberVolumes; i++ )
1771 UInt p1, p2, p3, p4;
1773 pointerVolume = &mesh.addVolume();
1774 pointerVolume->setId ( i );
1775 p1 = volumePointID[ 4 * i ];
1776 p2 = volumePointID[ 4 * i + 1 ];
1777 p3 = volumePointID[ 4 * i + 2 ];
1778 p4 = volumePointID[ 4 * i + 3 ];
1779 pointerVolume->setPoint ( 0, mesh.point ( p1 ) );
1780 pointerVolume->setPoint ( 1, mesh.point ( p2 ) );
1781 pointerVolume->setPoint ( 2, mesh.point ( p3 ) );
1782 pointerVolume->setPoint ( 3, mesh.point ( p4 ) );
1785 std::cout <<
"[importerMesh3D] added volumes." << std::endl;
1787 for (
UInt i = 0; i < numberBoundaryFaces; i++ )
1791 pointerFace = &mesh.addFace (
true );
1792 p1 = facePointID[ 3 * i ];
1793 p2 = facePointID[ 3 * i + 1 ];
1794 p3 = facePointID[ 3 * i + 2 ];
1796 pointerFace->setMarkerID ( markerID_Type ( bcnsurf[ i + 1 ] ) );
1797 pointerEdge->setId ( i );
1798 pointerFace->setPoint ( 0, mesh.point ( p1 ) );
1799 pointerFace->setPoint ( 1, mesh.point ( p2 ) );
1800 pointerFace->setPoint ( 2, mesh.point ( p3 ) );
1802 std::cout <<
"[importerMesh3D] added faces." << std::endl;
1806 if ( GeoShape::S_numPoints > 4 )
1817 if ( !checkMesh3D ( mesh, sw,
true, verbose, oStr, std::cerr, oStr ) )
1824 getVolumeFromFaces ( mesh, vols, oStr );
1826 oStr <<
"Volume enclosed by the mesh computed by integration on boundary faces" << std::endl
1827 <<
"INT(X) INT(Y) INT(Z) <- they should be equal and equal to" << std::endl
1828 <<
" the volume enclosed by the mesh " << std::endl
1829 << vols[ 0 ] <<
" " << vols[ 1 ] <<
" " << vols[ 2 ] << std::endl
1830 <<
"Boundary faces are defining aclosed surface if " 1831 << testClosedDomain ( mesh, oStr ) << std::endl
1832 <<
" is (almost) zero" << std::endl;
1847 template <
typename VectorType>
1849 saveNetgenSolution (std::string fileName,
1850 const VectorType& solution,
1851 std::string functionName =
"u")
1853 std::ofstream of (fileName.c_str() );
1855 of <<
"solution " << functionName <<
" -size =" << solution.size() <<
" -components=1 -type=nodal" << std::endl;
1857 for (
UInt i = 0; i < solution.size(); ++i )
1859 of << solution ( i ) << std::endl;
#define ASSERT_PRE0(X, A)
I use standard constructor/destructors.
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.
bool readMppFileHead(std::ifstream &myStream, UInt &numberVertices, UInt &numberBoundaryVertices, UInt &numberBoundaryFaces, UInt &numberBoundaryEdges, UInt &numberVolumes)
readMppFileHead - reads mesh++ Tetra meshes.
container_Type::const_iterator containerConstIterator_Type
Assert & error(const char *strMsg=0)
boost::numeric::ublas::vector< Real > Vector
uint32_type UInt
generic unsigned integer (used mainly for addressing)