42 #ifndef _IMPORTERMESH2D_HH_ 43 #define _IMPORTERMESH2D_HH_ 1
46 #include <boost/lambda/lambda.hpp> 49 #include <lifev/core/util/FortranWrapper.hpp> 50 #include <lifev/core/util/StringUtility.hpp> 52 #include <lifev/core/mesh/RegionMesh.hpp> 54 #include <lifev/core/mesh/MeshChecks.hpp> 65 I_F77& nptot, I_F77& nb, I_F77& nps, I_F77& nx,
66 I_F77& ndimn, I_F77& npe, I_F77& npb,
67 I_F77& npc, I_F77* iel,
68 I_F77& nd, R4_F77* coor, I_F77& ndc,
69 R4_F77& xmin, R4_F77& xmax, R4_F77& ymin,
70 R4_F77& ymax, I_F77* ib, I_F77& nbd,
71 I_F77* ic, I_F77* bc, I_F77* ie,
72 I_F77* cpl, R4_F77* xmed, I_F77& isw,
73 I_F77& ierr, FortranCharacterString filename );
77 I_F77& nptot, I_F77& npe, I_F77& nb,
78 I_F77& nps, I_F77& nx,
79 I_F77& npc, I_F77& ierr, FortranCharacterString filename );
600 template <
typename MC>
603 const std::string& fileName,
611 typename RegionMesh<GeoShape, MC>::point_Type* pp = 0;
612 typename RegionMesh<GeoShape, MC>::edge_Type* pe = 0;
613 typename RegionMesh<GeoShape, MC>::face_Type* pf = 0;
615 std::ifstream __is ( fileName.c_str() );
618 std::cerr <<
" Error in readFreeFemFile: File " << fileName
619 <<
" not found or locked" 625 UInt __nv, __nt, __ne, i1, i2, i3;
626 __is >> __nv >> __nt >> __ne;
629 debugStream ( 8000 ) <<
"number of vertices: " << __nv <<
"\n";
630 debugStream ( 8000 ) <<
"number of triangles: " << __nt <<
"\n";
631 debugStream ( 8000 ) <<
"number of edges: " << __ne <<
"\n";
636 std::vector<Real> __x (2 * __nv);
637 std::vector<
bool> __isonboundary (__nv);
638 std::vector<UInt> __whichboundary (__nv);
641 debugStream ( 8000 ) <<
"reading " << __nv <<
" nodes\n";
648 for (
UInt __i = 0; __i < __nv; ++ __i )
650 __is >> __x[ 2 * __i ] >> __x[ 2 * __i + 1 ] >> __whichboundary[ __i ];
651 __isonboundary[ __i ] = __whichboundary[ __i ];
652 __nbv += __isonboundary[ __i ];
657 std::vector<
int> __triangle_nodes ( 3 * __nt );
658 std::vector<
int> __triangle_label ( __nt );
661 debugStream ( 8000 ) <<
"reading " << __nt <<
" triangles\n";
664 std::map<UInt, UInt> edge_to_firstAdjacentElementIdentity, edge_to_firstAdjacentElementPosition;
667 for (
UInt __i = 0; __i < __nt; ++__i )
669 __is >> __triangle_nodes[ 3 * __i ]
670 >> __triangle_nodes[ 3 * __i + 1 ]
671 >> __triangle_nodes[ 3 * __i + 2 ]
672 >> __triangle_label[ __i ];
675 __triangle_nodes[3 * __i]--;
676 __triangle_nodes[3 * __i + 1]--;
677 __triangle_nodes[3 * __i + 2]--;
683 std::pair<
UInt,
bool> _check;
685 i1 = __triangle_nodes[ 3 * __i ];
686 i2 = __triangle_nodes[ 3 * __i + 1 ];
687 i3 = __triangle_nodes[ 3 * __i + 2 ];
689 _edge = makeBareEdge ( i1, i2 );
690 _check = _be.addIfNotThere ( _edge.first );
691 edge_to_firstAdjacentElementIdentity[ _check.first ] = __i;
692 edge_to_firstAdjacentElementPosition[ _check.first ] = 0;
694 _edge = makeBareEdge ( i2, i3 );
695 _check = _be.addIfNotThere ( _edge.first );
696 edge_to_firstAdjacentElementIdentity[ _check.first ] = __i;
697 edge_to_firstAdjacentElementPosition[ _check.first ] = 1;
699 _edge = makeBareEdge ( i3, i1 );
700 _check = _be.addIfNotThere ( _edge.first );
701 edge_to_firstAdjacentElementIdentity[ _check.first ] = __i;
702 edge_to_firstAdjacentElementPosition[ _check.first ] = 2;
710 std::vector<
int> __edge_nodes ( 2 * __ne );
711 std::vector<
int> __edge_label ( __ne );
715 for (
UInt __i = 0; __i < __ne; ++__i )
717 __is >> __edge_nodes[ 2 * __i ] >> __edge_nodes[ 2 * __i + 1 ] >> __edge_label[ __i ];
721 for (UInt i (0); i < __edge_nodes.size(); i++)
728 mesh.setMarkerID ( regionFlag );
732 mesh.setMaxNumEdges ( _be.size() );
733 mesh.setMaxNumGlobalEdges ( _be.size() );
736 mesh.setNumEdges ( _be.size() );
738 mesh.setNumBEdges ( __ne );
739 mesh.setMaxNumFaces ( __nt );
740 mesh.setMaxNumGlobalFaces ( __nt );
743 mesh.setNumFaces ( __nt);
745 mesh.setMaxNumPoints ( __nv,
true );
746 mesh.setMaxNumGlobalPoints ( __nv );
748 mesh.setNumVertices ( __nv );
749 mesh.setNumGlobalVertices ( __nv );
751 mesh.numBVertices() = __nbv;
752 mesh.setNumBPoints ( mesh.numBVertices() );
755 debugStream ( 8000 ) <<
"number of points : " << mesh.numPoints() <<
"\n";
756 debugStream ( 8000 ) <<
"number of boundary points : " << mesh.numBPoints() <<
"\n";
757 debugStream ( 8000 ) <<
"number of vertices : " << mesh.numVertices() <<
"\n";
758 debugStream ( 8000 ) <<
"number of boundary vertices : " << mesh.numBVertices() <<
"\n";
761 for (
UInt __i = 0; __i < __nv; ++__i )
763 pp = &mesh.addPoint ( __isonboundary[ __i ],
true );
764 pp->setMarkerID ( __whichboundary[ __i ] );
765 pp->x() = __x[ 2 * __i ];
766 pp->y() = __x[ 2 * __i + 1 ];
772 for (
UInt __i = 0; __i < __ne; ++__i )
774 pe = & ( mesh.addEdge (
true ) );
775 pe->setMarkerID ( markerID_Type ( __edge_label[ __i ] ) );
776 pe->setPoint ( 0, mesh.point ( __edge_nodes[ 2 * __i ] ) );
777 pe->setPoint ( 1, mesh.point ( __edge_nodes[ 2 * __i + 1 ] ) );
779 _edge = makeBareEdge ( __edge_nodes[ 2 * __i ], __edge_nodes[ 2 * __i + 1 ] );
780 UInt map_it ( _be.id ( _edge.first ) );
781 pe->firstAdjacentElementIdentity() = edge_to_firstAdjacentElementIdentity[ map_it ];
782 pe->firstAdjacentElementPosition() = edge_to_firstAdjacentElementPosition[ map_it ];
786 for (
UInt __i = 0; __i < __nt; ++__i )
788 pf = & ( mesh.addFace (
true) );
790 pf->setMarkerID ( markerID_Type ( __triangle_label[ __i ] ) );
791 pf->setPoint ( 0, mesh.point ( __triangle_nodes[ 3 * __i ] ) );
792 pf->setPoint ( 1, mesh.point ( __triangle_nodes[ 3 * __i + 1 ] ) );
793 pf->setPoint ( 2, mesh.point ( __triangle_nodes[ 3 * __i + 2 ] ) );
ID markerID_Type
markerID_Type is the type used to store the geometric entity marker IDs
Class for 3D, 2D and 1D Mesh.
container_Type::const_iterator containerConstIterator_Type
uint32_type UInt
generic unsigned integer (used mainly for addressing)