36 #include <type_traits> 40 std::map<elementType, VTKCellType> eMap =
42 {elementType::BAR, VTK_LINE},
43 {elementType::QUADRILATERAL, VTK_QUAD},
45 {elementType::HEXAGON, VTK_HEXAHEDRON},
46 {elementType::SPHERICAL, VTK_EMPTY_CELL},
47 {elementType::CYLINDRICAL, VTK_EMPTY_CELL},
48 {elementType::BRICK, VTK_HEXAHEDRON},
49 {elementType::LAGRANGE_BRICK, VTK_HEXAHEDRON},
50 {elementType::TETRAHEDRON, VTK_TETRA},
51 {elementType::HEXPRISM, VTK_HEXAGONAL_PRISM},
52 {elementType::PRISMATIC, VTK_WEDGE},
53 {elementType::OTHER, VTK_EMPTY_CELL}
60 std::map<VTKCellType, elementType> eMap =
62 {VTK_LINE, elementType::BAR},
63 {VTK_QUAD, elementType::QUADRILATERAL},
64 {VTK_QUADRATIC_QUAD, elementType::QUADRILATERAL},
66 {VTK_QUADRATIC_TRIANGLE, elementType::TRIANGLE},
67 {VTK_HEXAHEDRON, elementType::HEXAGON},
68 {VTK_QUADRATIC_HEXAHEDRON, elementType::HEXAGON},
69 {VTK_TETRA, elementType::TETRAHEDRON},
70 {VTK_QUADRATIC_TETRA, elementType::TETRAHEDRON},
71 {VTK_HEXAGONAL_PRISM, elementType::HEXPRISM},
72 {VTK_WEDGE, elementType::PRISMATIC},
73 {VTK_EMPTY_CELL, elementType::OTHER}
80 std::string tag = _tag;
82 if (tag ==
"reflective")
return surfaceBCTag::REFLECTIVE;
83 if (tag ==
"void")
return surfaceBCTag::VOID;
84 std::cerr <<
"Unknown surface tag " << tag << std::endl;
91 case surfaceBCTag::REFLECTIVE:
return "REFLECTIVE";
92 case surfaceBCTag::VOID:
return "VOID";
99 std::string tag = _tag;
101 if (tag ==
"bar")
return elementType::BAR;
102 if (tag ==
"quadrilateral")
return elementType::QUADRILATERAL;
104 if (tag ==
"hexagon")
return elementType::HEXAGON;
105 if (tag ==
"spherical")
return elementType::SPHERICAL;
106 if (tag ==
"cylindrical")
return elementType::CYLINDRICAL;
107 if (tag ==
"brick")
return elementType::BRICK;
108 if (tag ==
"lagrange_brick")
return elementType::LAGRANGE_BRICK;
109 if (tag ==
"tetrahedron")
return elementType::TETRAHEDRON;
110 if (tag ==
"hexprism")
return elementType::HEXPRISM;
111 if (tag ==
"prismatic")
return elementType::PRISMATIC;
112 std::cout <<
"Warning : Element type " << tag <<
" may be not supported" 114 return elementType::OTHER;
119 if (tag == elementType::BAR)
return "BAR";
120 if (tag == elementType::QUADRILATERAL)
return "QUADRILATERAL";
122 if (tag == elementType::HEXAGON)
return "HEXAGON";
123 if (tag == elementType::SPHERICAL)
return "SPHERICAL";
124 if (tag == elementType::CYLINDRICAL)
return "CYLINDRICAL";
125 if (tag == elementType::BRICK)
return "BRICK";
126 if (tag == elementType::LAGRANGE_BRICK)
return "LAGRANGE_BRICK";
127 if (tag == elementType::TETRAHEDRON)
return "TETRAHEDRON";
128 if (tag == elementType::HEXPRISM)
return "HEXPRISM";
129 if (tag == elementType::PRISMATIC)
return "PRISMATIC";
135 if (tag == elementType::BAR)
return (2 + order - 1);
136 if (tag == elementType::QUADRILATERAL && order == 1)
return 4;
137 if (tag == elementType::QUADRILATERAL && order == 2)
return 8;
140 if (tag == elementType::HEXAGON && order == 1)
return 8;
141 if (tag == elementType::HEXAGON && order == 2)
return 27;
142 if (tag == elementType::BRICK && order == 1)
return 8;
143 if (tag == elementType::BRICK && order == 2)
return 27;
144 if (tag == elementType::LAGRANGE_BRICK && order == 1)
return 8;
145 if (tag == elementType::LAGRANGE_BRICK && order == 2)
return 27;
146 if (tag == elementType::TETRAHEDRON && order == 1)
return 4;
147 if (tag == elementType::TETRAHEDRON && order == 2)
return 10;
148 if (tag == elementType::HEXPRISM && order == 1)
return 16;
149 if (tag == elementType::PRISMATIC && order == 1)
return 6;
150 if (tag == elementType::PRISMATIC && order == 2)
return 15;
151 std::cerr <<
"Unknown element/order combination\n";
157 if (tag == elementType::BAR)
return 2;
158 if (tag == elementType::QUADRILATERAL)
return 4;
160 if (tag == elementType::HEXAGON)
return 8;
161 if (tag == elementType::BRICK)
return 6;
162 if (tag == elementType::LAGRANGE_BRICK)
return 6;
163 if (tag == elementType::TETRAHEDRON)
return 4;
164 if (tag == elementType::HEXPRISM)
return 10;
165 if (tag == elementType::PRISMATIC)
return 6;
166 std::cerr <<
"Unknown element type\n";
174 : ifname(
""), isSupported(true)
185 std::ifstream fs(ifname);
188 std::cout <<
"Error opening file " << ifname << std::endl;
193 std::stringstream ss;
214 std::cout <<
"Reading PNT Mesh..." << std::endl;
215 std::cout <<
"Number of vertices : " << numVertices << std::endl;
216 std::cout <<
"Number of eLements : " << numElements << std::endl;
217 std::cout <<
"Number of dimensions : " << numDimensions << std::endl;
218 std::cout <<
"Number of blocks : " << numBlocks << std::endl;
219 std::cout <<
"Number of surfaces : " << numSurfaces << std::endl;
220 std::cout <<
"Number of internals surface : " << numSurfInternal << std::endl;
221 std::cout <<
"Number of boundary surface : " << numSurfBoundary << std::endl;
227 pntCrds.resize(numVertices, std::vector<double>(3, 0));
237 for (
int iBlk = 0; iBlk <
numBlocks; iBlk++)
249 std::cout << dms << std::endl;
253 std::cout <<
"================================================" 255 std::cout <<
"Processing block " << nb.
regionName << std::endl;
259 std::cout <<
"Num Nodes/Element : " << nb.
nodesPerElement << std::endl;
260 std::cout <<
"Element order : " << nb.
ordIntrp << std::endl;
261 std::cout <<
"Equation order : " << nb.
ordEquat << std::endl;
262 std::cout <<
"Element Type : " <<
elmTypeStr(nb.
eTpe) << std::endl;
270 std::cout <<
"Reading block...";
274 std::vector<idTyp> conn;
281 nb.
eConn[ibe] = conn;
320 for (
int i = 0; i < ni; i++)
325 for (
int i = 0; i < ni; i++)
330 for (
int i = 0; i < ni; i++)
334 std::cout <<
"..." << std::endl;
335 for (
int i = 0; i < ni; i++)
363 std::vector<double> crds;
374 vtkIdList *point_ids = imb->
getDataSet()->GetCell(i)->GetPointIds();
375 int numComponent = point_ids->GetNumberOfIds();
377 cn.resize(numComponent);
378 for (
int j = 0; j < numComponent; ++j)
379 cn[j] = point_ids->GetId(j);
382 VTKCellType type_id =
static_cast<VTKCellType
>(imb->
getDataSet()->GetCellType(i));
389 elmOrd.resize(numElements, -1);
390 for (
int iBlk = 0; iBlk <
numBlocks; iBlk++)
393 for (
auto it = elmBlkMap[iBlk].elmIds.begin();
394 it != elmBlkMap[iBlk].elmIds.end();
399 elmOrd[*it] = elmBlkMap[iBlk].ordIntrp;
406 for (
int iBlk = 0; iBlk <
numBlocks; iBlk++)
412 std::cout <<
"Block Name = " <<
elmBlks[iBlk].regionName << std::endl;
413 std::cout <<
"Block size = " <<
elmBlks[iBlk].numElementsInBlock
426 if (vct == VTK_QUADRATIC_TRIANGLE)
435 else if (vct == VTK_QUADRATIC_HEXAHEDRON)
521 std::cerr <<
"Invalid Block Id " << std::endl;
531 std::cerr <<
"Invalid Block Id " << std::endl;
541 std::cerr <<
"Invalid Element ID " << std::endl;
551 std::cerr <<
"Invalid Element ID " << std::endl;
563 case 1:
return VTK_TRIANGLE;
564 case 2:
return VTK_QUADRATIC_TRIANGLE;
565 default:
return VTK_HIGHER_ORDER_TRIANGLE;
571 case 1:
return VTK_QUAD;
572 case 2:
return VTK_QUADRATIC_QUAD;
573 default:
return VTK_HIGHER_ORDER_QUAD;
579 case 1:
return VTK_TETRA;
580 case 2:
return VTK_QUADRATIC_TETRA;
581 default:
return VTK_HIGHER_ORDER_TETRAHEDRON;
589 case 1:
return VTK_HEXAHEDRON;
590 case 2:
return VTK_QUADRATIC_HEXAHEDRON;
591 default:
return VTK_HIGHER_ORDER_HEXAHEDRON;
597 case 1:
return VTK_WEDGE;
598 case 2:
return VTK_QUADRATIC_WEDGE;
599 default:
return VTK_HIGHER_ORDER_WEDGE;
602 std::cerr <<
"Unknown element type " 603 <<
static_cast<std::underlying_type<elementType>::type
>(et)
604 <<
" order " << order << std::endl;
611 std::ofstream outputStream(fname.c_str());
612 if (!outputStream.good())
614 std::cout <<
"Output file stream is bad" << std::endl;
626 << std::setw(10) << 0
627 << std::setw(10) << 0
628 << std::setw(10) << 0
637 outputStream << std::setw(15)
639 << std::setprecision(8)
643 outputStream << std::endl;
648 outputStream << std::endl;
654 outputStream << std::setw(10) <<
elmBlks[ib].numElementsInBlock
655 << std::setw(10) <<
elmBlks[ib].numBoundarySurfacesInBlock
656 << std::setw(10) <<
elmBlks[ib].nodesPerElement
657 << std::setw(10) << 0
658 << std::setw(10) <<
elmBlks[ib].ordIntrp
659 << std::setw(10) <<
elmBlks[ib].ordEquat
664 << std::setw(16) << std::left <<
elmBlks[ib].regionName
669 for (
int ie = 0; ie <
elmBlks[ib].numElementsInBlock; ie++)
671 std::vector<int> econn;
674 for (
int im = 0; im < econn.size(); im++, lb++)
676 outputStream << std::setw(10) << std::right << econn[im] + 1;
680 outputStream << std::endl;
685 outputStream << std::endl;
689 for (
auto it =
elmBlks[ib].srfBCTag.begin();
690 it !=
elmBlks[ib].srfBCTag.end(); it++, lb++)
692 outputStream << std::setw(16) << std::left <<
bcTagStr(*it);
696 outputStream << std::endl;
700 outputStream << std::endl;
704 for (
auto it =
elmBlks[ib].srfBCEleRef.begin();
705 it !=
elmBlks[ib].srfBCEleRef.end();
708 outputStream << std::setw(10) << std::right << *it;
712 outputStream << std::endl;
716 outputStream << std::endl;
719 outputStream << std::setw(10) <<
elmBlks[ib].numElementsInBlock
720 << std::setw(10) <<
elmBlks[ib].numSurfPerEleInBlock
725 for (
auto it =
elmBlks[ib].glbSrfId.begin();
726 it !=
elmBlks[ib].glbSrfId.end();
729 outputStream << std::setw(10) << std::right << *it;
733 outputStream << std::endl;
737 outputStream << std::endl;
741 for (
auto it =
elmBlks[ib].adjBlkId.begin();
742 it !=
elmBlks[ib].adjBlkId.end();
745 outputStream << std::setw(10) << std::right << *it;
749 outputStream << std::endl;
753 outputStream << std::endl;
757 for (
auto it =
elmBlks[ib].adjElmId.begin();
758 it !=
elmBlks[ib].adjElmId.end();
761 outputStream << std::setw(10) << std::right << *it;
765 outputStream << std::endl;
769 outputStream << std::endl;
773 for (
auto it =
elmBlks[ib].adjRefId.begin();
774 it !=
elmBlks[ib].adjRefId.end();
777 outputStream << std::setw(10) << std::right << *it;
781 outputStream << std::endl;
785 outputStream << std::endl;
789 outputStream.close();
796 vtkSmartPointer<vtkDataSet> ds = imb->
getDataSet();
798 std::cerr <<
"No dataset is associated to the meshbase." << std::endl;
804 int nCl = ds->GetNumberOfCells();
806 for (
int ic = 0; ic < nCl; ic++)
808 vtkCell *vc = ds->GetCell(ic);
809 if (vc->GetCellDimension() == 2)
812 int ne = vc->GetNumberOfEdges();
813 for (
int ie = 0; ie < ne; ie++)
816 vtkCell *ve = vc->GetEdge(ie);
817 vtkIdList *pidl = ve->GetPointIds();
821 std::map<std::set<int>,
int>::const_iterator itSrfId;
822 std::pair<int, int> adjPair;
823 std::vector<int> adjCellId;
824 for (
int ipt = 0; ipt < pidl->GetNumberOfIds(); ipt++)
825 econn.insert(pidl->GetId(ipt));
826 auto ret1 =
connSet.insert(econn);
827 bool isNew = ret1.second;
835 adjPair.second = ie + 1;
845 adjPair.second = ie + 1;
849 std::cerr <<
"Found a repeated surface connectivity without id.";
855 bool isBndrSrf =
false;
856 adjCellId.push_back(ic + 1);
858 ds->GetCellNeighbors(ic, pidl, cidl);
859 if (cidl->GetNumberOfIds() == 0)
863 adjCellId.push_back(0);
881 elmSrfId[ic].push_back(itSrfId->second);
893 else if (vc->GetCellDimension() == 3)
896 int nfc = vc->GetNumberOfFaces();
897 for (
int ifc = 0; ifc < nfc; ifc++)
900 vtkCell *vf = vc->GetFace(ifc);
901 vtkIdList *pidl = vf->GetPointIds();
905 std::map<std::set<int>,
int>::const_iterator itSrfId;
906 std::pair<int, int> adjPair;
907 std::vector<int> adjCellId;
908 for (
int ipt = 0; ipt < pidl->GetNumberOfIds(); ipt++)
909 econn.insert(pidl->GetId(ipt));
910 auto ret1 =
connSet.insert(econn);
911 bool isNew = ret1.second;
919 adjPair.second = ifc + 1;
929 adjPair.second = ifc + 1;
933 std::cerr <<
"Found a repeated surface connectivity without id.";
939 bool isBndrSrf =
false;
940 adjCellId.push_back(ic + 1);
942 ds->GetCellNeighbors(ic, pidl, cidl);
943 if (cidl->GetNumberOfIds() == 0)
947 adjCellId.push_back(0);
965 elmSrfId[ic].push_back(itSrfId->second);
981 std::cout <<
"Number of boundary surfaces (edges) = " << numSurfBoundary
983 std::cout <<
"Number of internal surfaces (edges) = " <<
numSurfInternal 985 std::cout <<
"Total number of surfaces (edges) = " <<
numSurfaces 987 std::cout <<
"Srf ID = " << srfId << std::endl;
1005 for (
int iBlk = 0; iBlk <
numBlocks; iBlk++)
1007 std::cout <<
"Finished processing blocks." << std::endl;
1013 std::cout <<
"Working on block " << blkId << std::endl;
1014 elmBlks[blkId].numBoundarySurfacesInBlock = 0;
1016 int frstElmGlbIdx =
elmBlks[blkId].elmIds[0];
1019 elmBlks[blkId].srfBCTag.pop_back();
1021 for (
auto ie =
elmBlks[blkId].elmIds.begin();
1022 ie !=
elmBlks[blkId].elmIds.end();
1026 std::cout <<
"Working on element " << *ie << std::endl;
1032 for (
auto is =
elmSrfId[*ie].begin();
1049 elmBlks[blkId].numBoundarySurfacesInBlock++;
1052 elmBlks[blkId].srfBCTag.push_back(sbc);
1054 elmBlks[blkId].srfBCEleRef.push_back(*ie + 1 - frstElmGlbIdx);
1055 elmBlks[blkId].srfBCEleRef.push_back(srfRefId);
1057 elmBlks[blkId].adjElmId.push_back(0);
1058 elmBlks[blkId].adjBlkId.push_back(0);
1059 elmBlks[blkId].adjRefId.push_back(0);
1066 elmBlks[blkId].adjRefId.push_back(adjRefId);
1070 elmBlks[blkId].glbSrfId.push_back(*is + 1);
std::vector< int > adjRefId
std::vector< int > elmLocalId
A brief description of meshBase.
VTKCellType getVtkCellTag(elementType et, int order) const
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
int getElmOrder(int id) const
elementType getElmType(int id) const
std::vector< int > adjElmId
std::string elmTypeStr(elementType tag)
void pntPopulate(const meshBase *imb)
int elmNumSrf(elementType et)
std::map< int, std::set< int > > surfIdToConn
std::string getBlockName(int id) const
std::vector< std::vector< int > > elmSrfId
std::vector< int > elmOrd
std::set< std::set< int > > connSet
std::vector< int > srfBCEleRef
std::vector< int > glbSrfId
std::vector< int > adjBlkId
std::vector< elementType > elmTyp
vtkSmartPointer< vtkDataSet > getDataSet() const
get this meshes' dataSet
std::vector< std::vector< int > > elmConn
nemId_t getNumberOfPoints() const
return the number of points
int numBoundarySurfacesInBlock
void toLower(std::string &str)
std::vector< blockType > elmBlks
void updElmBlk(int blkId)
vtkIdType id
id in .inp file
surfaceBCTag bcTagNum(const std::string &tag)
elementType getBlockElmType(int id) const
std::vector< int > elmBlkId
std::map< int, std::vector< int > > surfAdjElmNum
std::vector< bool > surfOnBndr
std::map< std::set< int >, int > surfConnToId
elementType v2pEMap(VTKCellType vt)
VTKCellType p2vEMap(elementType et)
std::vector< std::vector< int > > eConn
std::vector< int > getElmConn(int id) const
std::map< int, std::vector< std::pair< int, int > > > surfAdjRefNum
std::vector< blockType > BlockMap
std::vector< std::vector< double > > pntCrds
void write(const std::string &fname) const
int elmNumNde(elementType et, int order)
nemId_t getNumberOfCells() const
return the number of cells
elementType elmTypeNum(const std::string &tag)
std::vector< surfaceBCTag > srfBCTag
std::string bcTagStr(surfaceBCTag tag)
std::vector< int > getPntConn(std::vector< int > &ci, elementType et, int eo) const