32 #include <vtkAppendFilter.h> 34 #include <vtkCellData.h> 35 #include <vtkCellTypes.h> 36 #include <vtkDataArray.h> 37 #include <vtkDataSetTriangleFilter.h> 38 #include <vtkExtractSelection.h> 39 #include <vtkGenericCell.h> 40 #include <vtkIdList.h> 41 #include <vtkIntArray.h> 42 #include <vtkPointData.h> 43 #include <vtkPoints.h> 44 #include <vtkSelection.h> 45 #include <vtkSelectionNode.h> 46 #include <vtkUnstructuredGrid.h> 79 if (fname.find(
".vt") != std::string::npos ||
80 fname.find(
".stl") != std::string::npos) {
81 auto *vtkmesh =
new vtkMesh(fname);
82 vtkmesh->setFileName(fname);
84 }
else if (fname.find(
".msh") != std::string::npos) {
85 std::cout <<
"Detected file in GMSH format" << std::endl;
86 std::cout <<
"Exporting to VTK ...." << std::endl;
87 return exportGmshToVtk(fname);
88 }
else if (fname.find(
".vol") != std::string::npos) {
89 std::cout <<
"Detected file in Netgen .vol format" << std::endl;
90 std::cout <<
"Exporting to VTK ...." << std::endl;
91 return exportVolToVtk(fname);
92 }
else if (fname.find(
".pntmesh") != std::string::npos) {
93 std::cout <<
"Detected file in PNTmesh format" << std::endl;
94 std::cout <<
"Processing the file ...." << std::endl;
95 return exportPntToVtk(fname);
96 }
else if (fname.find(
".g") != std::string::npos ||
97 fname.find(
".exo") != std::string::npos ||
98 fname.find(
".e") != std::string::npos) {
99 std::cout <<
"Detected file in Exodus II format" << std::endl;
100 std::cout <<
"Processing the file ...." << std::endl;
101 return exportExoToVtk(fname);
103 std::cout <<
"mesh files with extension " 104 << fname.substr(fname.find_last_of(
'.')) <<
" are not supported!" 113 const std::string &newname) {
114 return new vtkMesh(other, newname);
121 const std::vector<double> &yCrds,
122 const std::vector<double> &zCrds,
123 const std::vector<nemId_t> &elmConn,
124 const int cellType,
const std::string &newname) {
125 return new vtkMesh(xCrds, yCrds, zCrds, elmConn, cellType, newname);
131 const std::vector<double> &xCrds,
const std::vector<double> &yCrds,
132 const std::vector<double> &zCrds,
const std::vector<nemId_t> &elmConn,
133 const int cellType,
const std::string &newname) {
134 return std::unique_ptr<meshBase>(
141 vtkSmartPointer<vtkDataSet> other,
const std::string &newname) {
148 return std::unique_ptr<meshBase>(
mesh);
155 std::shared_ptr<meshBase> sharedMesh;
156 sharedMesh.reset(mesh);
163 vtkSmartPointer<vtkDataSet> other,
const std::string &newname) {
164 std::shared_ptr<meshBase>
mesh;
172 std::shared_ptr<meshBase>
mesh;
180 const std::vector<double> &xCrds,
const std::vector<double> &yCrds,
181 const std::vector<double> &zCrds,
const std::vector<nemId_t> &elmConn,
182 const int cellType,
const std::string &newname) {
183 std::shared_ptr<meshBase>
mesh;
184 mesh.reset(
meshBase::Create(xCrds, yCrds, zCrds, elmConn, cellType, newname));
197 if (!mbObjs.empty()) {
198 vtkSmartPointer<vtkAppendFilter> appender =
200 appender->MergePointsOn();
201 for (
int i = 0; i < mbObjs.size(); ++i) {
202 appender->AddInputData(mbObjs[i]->getDataSet());
207 std::cerr <<
"Nothing to stitch!" << std::endl;
216 const std::vector<std::shared_ptr<meshBase>> &_mbObjs) {
217 std::vector<meshBase *> mbObjs(_mbObjs.size());
218 for (
int i = 0; i < mbObjs.size(); ++i) {
219 mbObjs[i] = _mbObjs[i].get();
227 const std::vector<nemId_t> &cellIds) {
228 vtkSmartPointer<vtkIdTypeArray> selectionIds =
230 selectionIds->SetNumberOfComponents(1);
231 for (
const auto &cellId : cellIds) {
232 selectionIds->InsertNextValue(cellId);
234 return extractSelectedCells(mesh->
getDataSet(), selectionIds);
240 vtkSmartPointer<vtkDataSet>
mesh, vtkSmartPointer<vtkIdTypeArray> cellIds) {
241 vtkSmartPointer<vtkSelectionNode> selectionNode =
243 selectionNode->SetFieldType(vtkSelectionNode::CELL);
244 selectionNode->SetContentType(vtkSelectionNode::INDICES);
245 selectionNode->SetSelectionList(cellIds);
247 vtkSmartPointer<vtkSelection> selection =
249 selection->AddNode(selectionNode);
251 vtkSmartPointer<vtkExtractSelection> extractSelection =
254 extractSelection->SetInputData(0, mesh);
256 extractSelection->SetInputData(1, selection);
257 extractSelection->Update();
258 vtkSmartPointer<vtkDataSet> extractedCellMesh =
259 vtkDataSet::SafeDownCast(extractSelection->GetOutput());
262 return selectedCellMesh;
268 const bool pointOrCell)
const {
270 vtkPointData *pd = dataSet->GetPointData();
271 if (pd->GetNumberOfArrays()) {
272 for (
int i = 0; i < pd->GetNumberOfArrays(); ++i) {
273 if (name == (pd->GetArrayName(i) ? pd->GetArrayName(i) :
"NULL")) {
279 vtkCellData *cd = dataSet->GetCellData();
280 if (cd->GetNumberOfArrays()) {
281 for (
int i = 0; i < cd->GetNumberOfArrays(); ++i) {
282 if (name == (cd->GetArrayName(i) ? cd->GetArrayName(i) :
"Null")) {
296 const meshBase *mbObj,
const int numPartitions) {
299 if (mPart->partition(numPartitions)) {
303 std::vector<std::shared_ptr<meshBase>> mbParts(numPartitions);
304 for (
int i = 0; i < numPartitions; ++i) {
306 std::vector<std::vector<double>> comp_crds(mbObj->
getVertCrds());
308 std::vector<int> vtkConn_int(mPart->getConns(i));
309 std::vector<nemId_t> vtkConn(vtkConn_int.begin(), vtkConn_int.end());
310 for (
auto &&it : vtkConn) it -= 1;
313 basename += std::to_string(i);
318 mPart->getCrds(i, comp_crds[0]), mPart->getCrds(i, comp_crds[1]),
319 mPart->getCrds(i, comp_crds[2]), vtkConn, VTK_TETRA, basename);
321 vtkSmartPointer<vtkIntArray> nodePartitionIds =
323 nodePartitionIds->SetName(
"NodePartitionIds");
324 nodePartitionIds->SetNumberOfComponents(1);
325 nodePartitionIds->SetNumberOfTuples(mbParts[i]->getNumberOfPoints());
326 nodePartitionIds->FillComponent(0, i);
327 mbParts[i]->getDataSet()->GetPointData()->AddArray(nodePartitionIds);
329 vtkSmartPointer<vtkIntArray> cellPartitionIds =
331 cellPartitionIds->SetName(
"CellPartitionIds");
332 cellPartitionIds->SetNumberOfComponents(1);
333 cellPartitionIds->SetNumberOfTuples(mbParts[i]->getNumberOfCells());
334 cellPartitionIds->FillComponent(0, i);
335 mbParts[i]->getDataSet()->GetCellData()->AddArray(cellPartitionIds);
341 globalNodeIds->SetName(
"GlobalNodeIds");
342 globalNodeIds->SetNumberOfComponents(1);
343 globalNodeIds->SetNumberOfTuples(mbParts[i]->getNumberOfPoints());
344 globalNodeIds->SetNumberOfValues(mbParts[i]->getNumberOfPoints());
348 int globidx = it->second - 1;
349 int locidx = it->first - 1;
350 globalNodeIds->SetTuple1(idx, globidx);
351 mbParts[i]->globToPartNodeMap[globidx] = locidx;
352 mbParts[i]->partToGlobNodeMap[locidx] = globidx;
356 mbParts[i]->getDataSet()->GetPointData()->AddArray(globalNodeIds);
368 int globidx = it->second - 1;
369 int locidx = it->first - 1;
371 mbParts[i]->globToPartCellMap[globidx] = locidx;
372 mbParts[i]->partToGlobCellMap[locidx] = globidx;
388 const std::vector<int> &arrayIDs) {
389 std::unique_ptr<GaussCubature> cubature =
397 double dev_mult,
bool maxIsmin,
398 double sizeFactor,
int order) {
399 std::cout <<
"Size Factor = " << sizeFactor << std::endl;
400 std::unique_ptr<NEM::ADP::SizeFieldBase> sfobj =
402 maxIsmin, sizeFactor, order);
410 std::ifstream meshStream(fname);
411 if (!meshStream.good()) {
412 std::cout <<
"Error opening file " << fname << std::endl;
419 int numPoints = 0, numCells = 0, numPhysGrps = 0;
420 bool fndPhyGrp =
false;
421 std::vector<int> physGrpDims;
422 std::map<int, std::string> physGrpIdName;
423 std::vector<std::vector<std::vector<double>>> pointData;
424 std::vector<std::vector<std::vector<double>>> cellData;
425 std::vector<std::vector<double>> cellPhysGrpIds;
426 std::vector<std::string> pointDataNames;
427 std::vector<std::string> cellDataNames;
428 std::vector<std::string> fieldDataNames;
429 std::vector<std::string> fieldData;
433 points->SetDataTypeToDouble();
435 vtkSmartPointer<vtkUnstructuredGrid> dataSet_tmp =
438 std::map<int, int> trueIndex;
440 while (getline(meshStream, line)) {
441 if (line.find(
"$PhysicalNames") != -1) {
443 getline(meshStream, line);
444 std::stringstream ss(line);
446 std::cout <<
"Found " << numPhysGrps <<
" physical groups!\n";
447 for (
int i = 0; i < numPhysGrps; ++i) {
450 getline(meshStream, line);
451 std::stringstream ss(line);
452 ss >> grpDim >> grpId >> grpName;
453 grpName.erase(std::remove(grpName.begin(), grpName.end(),
'\"'),
459 physGrpDims.push_back(grpDim);
460 physGrpIdName[grpId] = grpName;
464 if (line.find(
"$Nodes") != -1) {
465 getline(meshStream, line);
466 std::stringstream ss(line);
471 points->SetNumberOfPoints(numPoints);
472 for (
int i = 0; i < numPoints; ++i) {
473 getline(meshStream, line);
474 std::stringstream ss(line);
475 ss >>
id >> std::setprecision(16) >> x >> y >> z;
481 points->SetPoint(i, point);
482 trueIndex.insert(std::pair<int, int>(
id, i));
485 dataSet_tmp->SetPoints(points);
488 if (line.find(
"$Elements") != -1) {
489 getline(meshStream, line);
491 std::stringstream ss(line);
493 int id, type, numTags;
496 dataSet_tmp->Allocate(numCells);
497 for (
int i = 0; i < numCells; ++i) {
498 getline(meshStream, line);
499 std::stringstream ss(line);
500 ss >>
id >> type >> numTags;
501 vtkSmartPointer<vtkIdList> vtkCellIds =
506 for (
int j = 0; j < numTags; ++j) ss >> tmp;
508 std::vector<double> physGrpId(1);
510 cellPhysGrpIds.push_back(physGrpId);
511 for (
int j = 0; j < numTags - 1; ++j) ss >> tmp;
513 for (
int j = 0; j < 3; ++j) {
516 vtkCellIds->InsertNextId(trueIndex[tmp]);
519 dataSet_tmp->InsertNextCell(VTK_TRIANGLE, vtkCellIds);
520 }
else if (type == 4) {
523 for (
int j = 0; j < numTags; ++j) ss >> tmp;
525 std::vector<double> physGrpId(1);
527 cellPhysGrpIds.push_back(physGrpId);
528 for (
int j = 0; j < numTags - 1; ++j) ss >> tmp;
530 for (
int j = 0; j < 4; ++j) {
533 vtkCellIds->InsertNextId(trueIndex[tmp]);
536 dataSet_tmp->InsertNextCell(VTK_TETRA, vtkCellIds);
537 }
else if (type == 3) {
540 for (
int j = 0; j < numTags; ++j) ss >> tmp;
542 std::vector<double> physGrpId(1);
544 cellPhysGrpIds.push_back(physGrpId);
545 for (
int j = 0; j < numTags - 1; ++j) ss >> tmp;
547 for (
int j = 0; j < 4; ++j) {
550 vtkCellIds->InsertNextId(trueIndex[tmp]);
553 dataSet_tmp->InsertNextCell(VTK_QUAD, vtkCellIds);
554 }
else if (type == 5) {
557 for (
int j = 0; j < numTags; ++j) ss >> tmp;
559 std::vector<double> physGrpId(1);
561 cellPhysGrpIds.push_back(physGrpId);
562 for (
int j = 0; j < numTags - 1; ++j) ss >> tmp;
564 for (
int j = 0; j < 8; ++j) {
567 vtkCellIds->InsertNextId(trueIndex[tmp]);
570 dataSet_tmp->InsertNextCell(VTK_HEXAHEDRON, vtkCellIds);
571 }
else if (type == 6) {
574 for (
int j = 0; j < numTags; ++j) ss >> tmp;
576 std::vector<double> physGrpId(1);
578 cellPhysGrpIds.push_back(physGrpId);
579 for (
int j = 0; j < numTags - 1; ++j) ss >> tmp;
581 for (
int j = 0; j < 6; ++j) {
584 vtkCellIds->InsertNextId(trueIndex[tmp]);
587 dataSet_tmp->InsertNextCell(VTK_WEDGE, vtkCellIds);
588 }
else if (type == 11) {
591 for (
int j = 0; j < numTags; ++j) ss >> tmp;
593 std::vector<double> physGrpId(1);
595 cellPhysGrpIds.push_back(physGrpId);
596 for (
int j = 0; j < numTags - 1; ++j) ss >> tmp;
598 for (
int j = 0; j < 10; ++j) {
601 vtkCellIds->InsertNextId(trueIndex[tmp]);
604 dataSet_tmp->InsertNextCell(VTK_QUADRATIC_TETRA, vtkCellIds);
608 <<
"Warning: Only triangular, quadrilateral, " 609 "tetrahedral, hexahedral, wedge, and quadratic tetrahedral" 610 "elements are supported, " 611 <<
"everything else is ignored! " << std::endl;
619 if (line.find(
"$NodeData") != -1) {
620 std::vector<std::vector<double>> currPointData;
621 getline(meshStream, line);
622 std::stringstream ss(line);
624 ss >> num_string_tags;
625 std::string dataname;
626 for (
int i = 0; i < num_string_tags; ++i) {
627 getline(meshStream, line);
629 std::stringstream ss(line);
633 dataname.erase(std::remove(dataname.begin(), dataname.end(),
'\"'),
635 pointDataNames.push_back(dataname);
636 getline(meshStream, line);
637 std::stringstream ss1(line);
639 ss1 >> num_real_tags;
640 for (
int i = 0; i < num_real_tags; ++i) getline(meshStream, line);
642 getline(meshStream, line);
643 std::stringstream ss2(line);
646 int dt, dim, numFields, tmp;
647 for (
int i = 0; i < num_int_tags; ++i) {
648 getline(meshStream, line);
649 std::stringstream ss(line);
659 for (
int i = 0; i < numFields; ++i) {
660 std::vector<double>
data(dim);
663 getline(meshStream, line);
664 std::stringstream ss(line);
666 for (
int j = 0; j < dim; ++j) {
670 currPointData.push_back(data);
672 pointData.push_back(currPointData);
675 if (line.find(
"$ElementData") != -1) {
676 std::vector<std::vector<double>> currCellData;
677 getline(meshStream, line);
678 std::stringstream ss(line);
680 ss >> num_string_tags;
681 std::string dataname;
682 for (
int i = 0; i < num_string_tags; ++i) {
683 getline(meshStream, line);
685 std::stringstream ss(line);
689 dataname.erase(std::remove(dataname.begin(), dataname.end(),
'\"'),
691 cellDataNames.push_back(dataname);
692 getline(meshStream, line);
693 std::stringstream ss1(line);
695 ss1 >> num_real_tags;
696 for (
int i = 0; i < num_real_tags; ++i) getline(meshStream, line);
698 getline(meshStream, line);
699 std::stringstream ss2(line);
702 int dt, dim, numFields, tmp;
703 for (
int i = 0; i < num_int_tags; ++i) {
704 getline(meshStream, line);
705 std::stringstream ss(line);
715 for (
int i = 0; i < numFields; ++i) {
716 std::vector<double>
data(dim);
719 getline(meshStream, line);
720 std::stringstream ss(line);
722 for (
int j = 0; j < dim; ++j) {
726 currCellData.push_back(data);
728 cellData.push_back(currCellData);
733 cellDataNames.push_back(
"PhysGrpId");
734 cellData.push_back(cellPhysGrpIds);
740 vtkmesh->
dataSet = dataSet_tmp;
742 if (numCells == 0) std::cerr <<
"Warning: No cells were found in the mesh!\n";
745 std::cerr <<
"Warning: No points were found in the mesh!\n";
748 for (
int i = 0; i < pointData.size(); ++i)
753 for (
int i = 0; i < cellData.size(); ++i)
759 std::cout <<
"vtkMesh constructed" << std::endl;
768 nglib::Ng_Mesh *Ngmesh;
770 Ngmesh = nglib::Ng_NewMesh();
772 int status = nglib::Ng_MergeMesh(Ngmesh, &fname[0u]);
774 std::cout <<
"Error: NetGen Returned: " << status << std::endl;
775 std::cout <<
"Could not load " << fname <<
" into netgen" << std::endl;
782 vtkSmartPointer<vtkUnstructuredGrid> dataSet_tmp =
784 int numNgPoints = nglib::Ng_GetNP(Ngmesh);
785 int numSurfCells = nglib::Ng_GetNSE(Ngmesh);
786 int numVolCells = nglib::Ng_GetNE(Ngmesh);
789 points->SetNumberOfPoints(numNgPoints);
790 for (
int i = 1; i <= numNgPoints; ++i) {
792 nglib::Ng_GetPoint(Ngmesh, i, point);
794 points->SetPoint(i - 1, point);
797 dataSet_tmp->SetPoints(points);
800 dataSet_tmp->Allocate(numSurfCells + numVolCells);
802 for (
int i = 1; i <= numSurfCells; ++i) {
805 nglib::Ng_GetSurfaceElement(Ngmesh, i, tri);
806 for (
int j = 0; j < 3; ++j) {
808 vtkcellIds->InsertNextId(tri[j] - 1);
811 dataSet_tmp->InsertNextCell(VTK_TRIANGLE, vtkcellIds);
814 for (
int i = 1; i <= numVolCells; ++i) {
817 nglib::Ng_GetVolumeElement(Ngmesh, i, tet);
818 for (
int j = 0; j < 4; ++j) {
820 vtkcellIds->InsertNextId(tet[j] - 1);
823 dataSet_tmp->InsertNextCell(VTK_TETRA, vtkcellIds);
829 vtkmesh->
dataSet = dataSet_tmp;
834 std::cout <<
"vtkMesh constructed" << std::endl;
836 if (Ngmesh) nglib::Ng_DeleteMesh(Ngmesh);
840 std::cerr <<
"ENABLE_NETGEN is not used during build." 841 <<
" Build with ENABLE_NETGEN to use this function." << std::endl;
868 vtkSmartPointer<vtkUnstructuredGrid> dataSet_tmp =
875 points->SetNumberOfPoints(numPoints);
876 for (
int i = 0; i < numPoints; ++i) {
877 std::vector<double> point;
880 points->SetPoint(i, &point[0]);
883 dataSet_tmp->SetPoints(points);
886 dataSet_tmp->Allocate(numVolCells);
887 for (
int i = 0; i < numVolCells; ++i) {
888 std::cout <<
"Element " << i << std::endl;
890 std::vector<int> conn;
894 for (
int j = 0; j < conn.size(); ++j) {
896 vtkcellIds->InsertNextId(conn[j]);
899 dataSet_tmp->InsertNextCell(vct, vtkcellIds);
902 vtkmesh->
dataSet = dataSet_tmp;
911 std::cout <<
"vtkMesh constructed" << std::endl;
920 int CPU_word_size, IO_word_size;
923 CPU_word_size =
sizeof(float);
929 ex_open(fname.c_str(), EX_READ, &CPU_word_size, &IO_word_size, &version);
936 vtkSmartPointer<vtkUnstructuredGrid> dataSet_tmp =
949 _exErr = ex_inquire(fid, EX_INQ_API_VERS, &num_props, &fdum, &cdum);
951 std::cout <<
"Exodus II API version is " << fdum << std::endl;
953 _exErr = ex_inquire(fid, EX_INQ_DB_VERS, &num_props, &fdum, &cdum);
955 std::cout <<
"Exodus II Database version is " << fdum << std::endl;
957 _exErr = ex_inquire(fid, EX_INQ_DIM, &num_props, &fdum, &cdum);
959 std::cout <<
"Number of coordinate dimensions is " << num_props << std::endl;
963 _exErr = ex_inquire(fid, EX_INQ_NODES, &num_props, &fdum, &cdum);
965 numPoints = num_props;
966 std::cout <<
"Number of points " << numPoints << std::endl;
968 _exErr = ex_inquire(fid, EX_INQ_ELEM, &num_props, &fdum, &cdum);
970 numVolCells = num_props;
971 std::cout <<
"Number of elements " << numVolCells << std::endl;
973 _exErr = ex_inquire(fid, EX_INQ_ELEM_BLK, &num_props, &fdum, &cdum);
975 numElmBlk = num_props;
976 std::cout <<
"Number of element blocks " << numElmBlk << std::endl;
978 _exErr = ex_inquire(fid, EX_INQ_NODE_SETS, &num_props, &fdum, &cdum);
980 numNdeSet = num_props;
981 std::cout <<
"Number of node sets " << numNdeSet << std::endl;
983 _exErr = ex_inquire(fid, EX_INQ_SIDE_SETS, &num_props, &fdum, &cdum);
985 numSideSet = num_props;
986 std::cout <<
"Number of side sets " << numSideSet << std::endl;
989 std::vector<float> x, y, z;
990 x.resize(numPoints, 0);
991 y.resize(numPoints, 0);
992 z.resize(numPoints, 0);
993 _exErr = ex_get_coord(fid, &x[0], &y[0], &z[0]);
997 points->SetNumberOfPoints(numPoints);
998 for (
int i = 0; i < numPoints; ++i) {
999 std::vector<double> pt = {x[i], y[i], z[i]};
1000 points->SetPoint(i, &pt[0]);
1003 dataSet_tmp->SetPoints(points);
1007 dataSet_tmp->Allocate(numVolCells);
1011 blocks->SetNumberOfValues(numVolCells);
1012 blocks->SetName(
"BlockId");
1016 for (
int iEB = 1; iEB <= numElmBlk; iEB++) {
1017 int num_el_in_blk, num_nod_per_el, num_attr ;
1019 char elem_type[MAX_STR_LENGTH + 1];
1021 _exErr = ex_get_elem_block(fid, iEB, elem_type, &num_el_in_blk,
1022 &num_nod_per_el, &num_attr);
1024 "Problem reading element block parameters.\n");
1026 std::vector<int> conn;
1027 conn.resize(num_el_in_blk * num_nod_per_el, 0);
1028 _exErr = ex_get_elem_conn(fid, iEB, &conn[0]);
1030 _exErr,
"Problem reading element block connectivities.\n");
1038 for (
int iEl = 0; iEl < num_el_in_blk; ++iEl) {
1042 for (
int jc = iEl * num_nod_per_el; jc < (iEl + 1) * num_nod_per_el;
1045 vtkcellIds->InsertNextId(conn[jc] - 1);
1048 dataSet_tmp->InsertNextCell(vct, vtkcellIds);
1050 vtkIdType i = count;
1051 blocks->SetValue(i, iEB);
1059 vtkmesh->
dataSet = dataSet_tmp;
1063 vtkmesh->
dataSet->GetCellData()->AddArray(blocks);
1067 std::cout <<
"vtkMesh constructed" << std::endl;
1070 _exErr = ex_close(fid);
1079 if (!outputStream.good()) {
1080 std::cout <<
"Output file stream is bad" << std::endl;
1085 std::cout <<
"No data to write" << std::endl;
1089 outputStream <<
"$MeshFormat" << std::endl
1090 <<
"2.2 0 8" << std::endl
1091 <<
"$EndMeshFormat" << std::endl;
1095 for (
int i = 0; i < numCells; i++) {
1096 type_id = dataSet->GetCellType(i);
1097 if (!(type_id == 3 || type_id == 5 || type_id == 10 || type_id == 9)) {
1098 std::cout <<
"Error: Only tetrahedral, triangular, and quadrilateral" 1099 <<
" meshes can be written to gmsh format" << std::endl;
1105 outputStream <<
"$Nodes" << std::endl << numPoints << std::endl;
1106 for (
int i = 0; i < numPoints; ++i) {
1107 std::vector<double> pntcrds = getPoint(i);
1108 outputStream << i + 1 <<
" " << pntcrds[0] <<
" " << pntcrds[1] <<
" " 1109 << pntcrds[2] <<
" " << std::endl;
1111 outputStream <<
"$EndNodes" << std::endl;
1114 outputStream <<
"$Elements" << std::endl << numCells << std::endl;
1115 for (
int i = 0; i < numCells; ++i) {
1116 vtkIdList *point_ids = dataSet->GetCell(i)->GetPointIds();
1117 int numComponent = point_ids->GetNumberOfIds();
1118 type_id = dataSet->GetCell(i)->GetCellType();
1119 outputStream << i + 1 <<
" ";
1120 switch (numComponent) {
1122 outputStream << 1 <<
" " << 2 <<
" " << 1 <<
" " << 1 <<
" ";
1126 outputStream << 2 <<
" " << 2 <<
" " << 1 <<
" " << 1 <<
" ";
1132 outputStream << 4 <<
" " << 2 <<
" " << 1 <<
" " << 1 <<
" ";
1134 }
else if (type_id == 9)
1136 outputStream << 3 <<
" " << 2 <<
" " << 1 <<
" " << 1 <<
" ";
1140 std::cerr <<
"Cells with 4 components must be tet or quad." 1147 std::cerr <<
"Components in cell should be <= 4" << std::endl;
1151 for (
int j = 0; j < numComponent; ++j)
1152 outputStream << point_ids->GetId(j) + 1 <<
" ";
1153 outputStream << std::endl;
1155 outputStream <<
"$EndElements" << std::endl;
1161 const std::string &pointOrCell,
int arrayID) {
1163 writeMSH(outputStream);
1165 if (!outputStream.good()) {
1166 std::cout <<
"Output file stream is bad" << std::endl;
1170 if (!pointOrCell.compare(
"point")) {
1173 vtkPointData *pointData = dataSet->GetPointData();
1175 int numArr = pointData->GetNumberOfArrays();
1176 if (arrayID >= numArr) {
1177 std::cout <<
"ERROR: arrayID is out of bounds" << std::endl;
1178 std::cout <<
"There are " << numArr <<
" point data arrays" 1181 }
else if (numArr < 1) {
1182 std::cout <<
"no point data found" << std::endl;
1185 vtkDataArray *da = pointData->GetArray(arrayID);
1187 int numComponent = da->GetNumberOfComponents();
1188 int numTuple = da->GetNumberOfTuples();
1189 std::string tmpname =
"PointArray";
1190 tmpname += std::to_string(arrayID);
1191 outputStream <<
"$NodeData" << std::endl
1194 << (pointData->GetArrayName(arrayID)
1195 ? pointData->GetArrayName(arrayID)
1197 <<
"\"" << std::endl
1202 << numComponent << std::endl
1203 << numTuple << std::endl;
1204 for (
int j = 0; j < numTuple; ++j) {
1205 double *
data = da->GetTuple(j);
1206 outputStream << j + 1 <<
" ";
1207 for (
int k = 0; k < numComponent; ++k) {
1208 outputStream << data[k] <<
" ";
1210 outputStream << std::endl;
1212 outputStream <<
"$EndNodeData" << std::endl;
1215 }
else if (!pointOrCell.compare(
"cell")) {
1219 vtkCellData *cellData = dataSet->GetCellData();
1221 int numArr = cellData->GetNumberOfArrays();
1222 if (arrayID >= numArr) {
1223 std::cout <<
"ERROR: arrayID is out of bounds" << std::endl;
1224 std::cout <<
"There are " << numArr <<
" cell data arrays" << std::endl;
1226 }
else if (numArr < 1) {
1227 std::cout <<
"no cell data found" << std::endl;
1230 vtkDataArray *da = cellData->GetArray(arrayID);
1232 int numComponent = da->GetNumberOfComponents();
1233 int numTuple = da->GetNumberOfTuples();
1234 std::string tmpname =
"CellArray";
1235 tmpname += std::to_string(arrayID);
1236 outputStream <<
"$ElementData" << std::endl
1239 << (cellData->GetArrayName(arrayID)
1240 ? cellData->GetArrayName(arrayID)
1242 <<
"\"" << std::endl
1247 << numComponent << std::endl
1248 << numTuple << std::endl;
1249 for (
int j = 0; j < numTuple; ++j) {
1250 double *
data = da->GetTuple(j);
1251 outputStream << j + 1 <<
" ";
1252 for (
int k = 0; k < numComponent; ++k) {
1253 outputStream << data[k] <<
" ";
1255 outputStream << std::endl;
1257 outputStream <<
"$EndElementData" << std::endl;
1266 const std::string &pointOrCell,
int arrayID,
1268 if (!outputStream.good()) {
1269 std::cout <<
"Output file stream is bad" << std::endl;
1274 std::cout <<
"No data to write" << std::endl;
1278 outputStream <<
"$MeshFormat" << std::endl
1279 <<
"2.2 0 8" << std::endl
1280 <<
"$EndMeshFormat" << std::endl;
1284 getNumberOfPoints();
1288 for (
int i = 0; i < numCells; i++) {
1289 int type_id = dataSet->GetCellType(i);
1290 if (!(type_id == 3 || type_id == 5 || type_id == 10 || type_id == 9)) {
1291 std::cout <<
"Error: Only tetrahedral, triangular, and quadrilateral" 1292 <<
" meshes can be written to gmsh format" << std::endl;
1295 if (!(type_id == 10)) num_bad += 1;
1299 outputStream <<
"$Nodes" << std::endl << numPoints << std::endl;
1300 for (
int i = 0; i < numPoints; ++i) {
1301 std::vector<double> pntcrds = getPoint(i);
1302 outputStream << i + 1 <<
" ";
1303 outputStream << std::setprecision(16) << pntcrds[0] <<
" " << pntcrds[1]
1304 <<
" " << pntcrds[2] <<
" " << std::endl;
1306 outputStream <<
"$EndNodes" << std::endl;
1309 outputStream <<
"$Elements" << std::endl << numCells - num_bad << std::endl;
1311 for (
int i = 0; i < numCells; ++i) {
1312 vtkIdList *point_ids = dataSet->GetCell(i)->GetPointIds();
1313 int numComponent = point_ids->GetNumberOfIds();
1314 int type_id = dataSet->GetCellType(i);
1315 if (type_id == 10) {
1316 outputStream << i + 1 <<
" ";
1317 switch (numComponent) {
1322 outputStream << 2 <<
" " << 2 <<
" " << 1 <<
" " << 1 <<
" ";
1326 outputStream << 4 <<
" " << 2 <<
" " << 1 <<
" " << 1 <<
" ";
1331 std::cerr <<
"Components in cell should be less than 4" << std::endl;
1335 for (
int j = 0; j < numComponent; ++j)
1336 outputStream << point_ids->GetId(j) + 1 <<
" ";
1337 outputStream << std::endl;
1341 outputStream <<
"$EndElements" << std::endl;
1343 vtkCellData *cellData = dataSet->GetCellData();
1344 vtkDataArray *da = cellData->GetArray(arrayID);
1346 std::string tmpname =
"CellArray";
1347 tmpname += std::to_string(arrayID);
1349 <<
"$ElementData" << std::endl
1352 << (cellData->GetArrayName(arrayID) ? cellData->GetArrayName(arrayID)
1354 <<
"\"" << std::endl
1360 << numCells - num_bad << std::endl;
1361 for (
int j = 0; j < numCells; ++j) {
1362 int type_id = dataSet->GetCellType(j);
1363 if (type_id == 10) {
1364 double *
data = da->GetTuple(j);
1365 outputStream << j + 1 <<
" ";
1366 outputStream << data[0] <<
" ";
1367 outputStream << std::endl;
1370 outputStream <<
"$EndElementData" << std::endl;
1377 const std::map<int, int> &patchMap) {
1378 std::ofstream outputStream(mapFile);
1379 if (!outputStream.good()) {
1380 std::cout <<
"Error opening file " << mapFile << std::endl;
1389 const std::map<int, int> &patchMap) {
1390 outputStream << patchMap.size() << std::endl;
1391 outputStream << patchMap.size() << std::endl;
1392 auto it = patchMap.begin();
1393 int normPatchNo = 1;
1394 while (it != patchMap.end()) {
1395 for (
int i = 0; i < 2; ++i) {
1396 outputStream << std::setw(2) << std::left << it->first <<
" ";
1398 outputStream << std::setw(2) << std::left << normPatchNo <<
" ";
1399 outputStream << std::endl;
1408 const std::string &mapFile,
1409 std::ofstream &outputStream) {
1410 if (!surfWithPatches) {
1411 std::cout <<
"surface mesh is empty!" << std::endl;
1414 if (surfWithPatches->
IsArrayName(
"patchNo", 1) == -1) {
1415 std::cout <<
"surface mesh must have patchNo cell array" << std::endl;
1418 vtkSmartPointer<vtkIdList> facePtIds;
1419 vtkSmartPointer<vtkIdList> sharedCellPtIds =
1421 vtkSmartPointer<vtkGenericCell> genCell1 =
1423 vtkSmartPointer<vtkGenericCell> genCell2 =
1425 std::map<std::vector<nemId_t>, std::pair<nemId_t, nemId_t>,
1429 vtkSmartPointer<vtkStaticCellLocator> surfCellLocator =
1432 int nVerticesPerFaceMax = 0;
1434 int nFacesPerCellMax = 0;
1436 for (
nemId_t i = 0; i < this->getNumberOfCells(); ++i) {
1438 dataSet->GetCell(i, genCell1);
1441 int numFaces = genCell1->GetNumberOfFaces();
1443 (nFacesPerCellMax < numFaces ? numFaces : nFacesPerCellMax);
1444 for (
int j = 0; j < numFaces; ++j) {
1445 vtkCell *face = genCell1->GetFace(j);
1447 vtkIdType numVerts = face->GetNumberOfPoints();
1448 nVerticesPerFaceMax =
1449 (nVerticesPerFaceMax < numVerts ? numVerts : nVerticesPerFaceMax);
1450 facePtIds = face->GetPointIds();
1451 dataSet->GetCellNeighbors(i, facePtIds, sharedCellPtIds);
1452 std::vector<nemId_t> facePntIds(numVerts);
1453 for (vtkIdType k = 0; k < numVerts; ++k) {
1454 facePntIds[k] = face->GetPointId(k) + 1;
1458 if (sharedCellPtIds->GetNumberOfIds()) {
1460 std::pair<std::vector<nemId_t>, std::pair<nemId_t, nemId_t>>(
1462 std::make_pair(i + 1, sharedCellPtIds->GetId(0) + 1)));
1464 double p1[3], p2[3], p3[3];
1465 face->GetPoints()->GetPoint(0, p1);
1466 face->GetPoints()->GetPoint(1, p2);
1467 face->GetPoints()->GetPoint(2, p3);
1468 double faceCenter[3];
1469 for (vtkIdType k = 0; k < numVerts; ++k) {
1470 faceCenter[k] = (p1[k] + p2[k] + p3[k]) / 3.0;
1472 vtkIdType closestCellId;
1475 double closestPoint[3];
1477 surfCellLocator->FindClosestPoint(faceCenter, closestPoint, genCell2,
1478 closestCellId, subId, minDist2);
1482 ->GetArray(
"patchNo")
1483 ->GetTuple(closestCellId, patchNo);
1485 std::pair<std::vector<nemId_t>, std::pair<nemId_t, nemId_t>>(
1486 facePntIds, std::make_pair(i + 1, -1 * patchNo[0])));
1491 std::map<int, int> patchMap;
1494 surfWithPatches->
getDataSet()->GetCellData()->GetArray(
"patchNo")->GetTuple(
1496 patchMap.insert(std::pair<int, int>(patchNo[0], i));
1502 outputStream << 3 <<
" " << 1 <<
" " << patchMap.size() << std::endl;
1503 outputStream << this->getNumberOfPoints() <<
" " << faceMap.size() <<
" " 1504 << this->getNumberOfCells() <<
" " << nVerticesPerFaceMax <<
" " 1505 << nFacesPerCellMax << std::endl;
1506 for (
int i = 0; i < this->getNumberOfPoints(); ++i) {
1507 std::vector<double> pnt(this->getPoint(i));
1508 outputStream << std::setw(21) << std::fixed << std::setprecision(15)
1509 << pnt[0] <<
" " << pnt[1] <<
" " << pnt[2] << std::endl;
1512 auto it = faceMap.begin();
1513 while (it != faceMap.end()) {
1514 outputStream << it->first.size() <<
" ";
1515 auto faceIdIter = it->first.begin();
1516 while (faceIdIter != it->first.end()) {
1517 outputStream << *faceIdIter <<
" ";
1520 outputStream << it->second.first <<
" " << it->second.second << std::endl;
1528 const std::string &mapFile,
1529 const std::string &ofname) {
1530 std::ofstream outputStream(ofname);
1531 if (!outputStream.good()) {
1532 std::cout <<
"Cannot open file " << ofname << std::endl;
1535 writeCobalt(surfWithPatches, mapFile, outputStream);
1541 const std::string &pointOrCell,
int arrayID,
1543 std::ofstream outputStream(fname.c_str());
1544 writeMSH(outputStream, pointOrCell, arrayID, onlyVol);
1550 std::ofstream outputStream(fname.c_str());
1551 writeMSH(outputStream);
1557 const std::string &pointOrCell,
int arrayID) {
1558 std::ofstream outputStream(fname.c_str());
1559 writeMSH(outputStream, pointOrCell, arrayID);
1566 double dev_mult,
bool maxIsmin,
double edge_scale,
1567 const std::string &ofname,
bool transferData,
1568 double sizeFactor,
bool constrainBoundary) {
1570 std::unique_ptr<NEM::ADP::Refine> refineobj =
1571 std::unique_ptr<NEM::ADP::Refine>(
1573 edge_scale, ofname, sizeFactor));
1574 refineobj->
run(transferData, constrainBoundary);
1576 std::cerr <<
"Cannot use meshBase::refineMesh without Gmsh. Please configure " 1577 "with ENABLE_GMSH=ON.\n";
1584 const std::string &ofname,
bool transferData) {
1586 std::unique_ptr<NEM::ADP::Refine> refineobj =
1588 this, method, arrayID, 0.0,
false, 0.0, ofname, 1.0, _order));
1589 refineobj->
run(transferData);
1591 std::cerr <<
"Cannot use meshBase::refineMesh without Gmsh. Please configure " 1592 "with ENABLE_GMSH=ON.\n";
1600 const std::string &arrayName,
double dev_mult,
1601 bool maxIsmin,
double edge_scale,
1602 const std::string &ofname,
bool transferData,
1603 double sizeFactor) {
1604 int arrayID = IsArrayName(arrayName);
1605 if (arrayID == -1) {
1606 std::cout <<
"Array " << arrayName
1607 <<
" not found in set of point data arrays" << std::endl;
1610 refineMesh(method, arrayID, dev_mult, maxIsmin, edge_scale, ofname,
1611 transferData, sizeFactor);
1617 const std::string &arrayName,
int order,
1618 const std::string &ofname,
bool transferData) {
1619 int arrayID = IsArrayName(arrayName);
1620 if (arrayID == -1) {
1621 std::cout <<
"Array " << arrayName
1622 <<
" not found in set of point data arrays" << std::endl;
1626 refineMesh(method, arrayID, order, ofname, transferData);
1632 const std::string &ofname,
bool transferData,
1633 bool constrainBoundary) {
1634 refineMesh(method, 0, 0,
false, edge_scale, ofname, transferData, 1.0,
1641 vtkSmartPointer<vtkStaticCellLocator> cellLocator =
1643 cellLocator->SetDataSet(dataSet);
1644 cellLocator->BuildLocator();
1650 pointLocator->SetDataSet(dataSet);
1651 pointLocator->BuildLocator();
1652 return pointLocator;
1658 std::unique_ptr<MeshQuality> qualCheck =
1659 std::unique_ptr<MeshQuality>(
new MeshQuality(
this));
1671 std::cerr <<
"Meshes don't have the same number of points or cells" 1677 std::vector<double> coord1 = mesh1->
getPoint(i);
1678 std::vector<double> coord2 = mesh2->
getPoint(i);
1679 for (
int j = 0; j < 3; ++j) {
1680 if (std::fabs((coord1[j] - coord2[j]) / coord2[j]) > tol) {
1681 std::cerr <<
"Meshes differ in point coordinates" << std::endl;
1682 std::cerr <<
"Index " << i <<
" Component " << j << std::endl;
1683 std::cerr <<
"Coord 1 " << std::setprecision(15) << coord1[j]
1684 <<
" Coord 2 " << std::setprecision(15) << coord2[j]
1686 std::cerr <<
"Meshes differ in point coordinates" << std::endl;
1693 std::vector<std::vector<double>> cell1 = mesh1->
getCellVec(i);
1694 std::vector<std::vector<double>> cell2 = mesh2->
getCellVec(i);
1695 if (cell1.size() != cell2.size()) {
1696 std::cerr <<
"Meshes differ in cells" << std::endl;
1699 for (
int j = 0; j < cell1.size(); ++j) {
1700 for (
int k = 0; k < 3; ++k) {
1701 if (std::fabs((cell1[j][k] - cell2[j][k]) / cell2[j][k]) > tol) {
1702 std::cerr <<
"Meshes differ in cells" << std::endl;
1713 int numArr1 = pd1->GetNumberOfArrays();
1714 int numArr2 = pd2->GetNumberOfArrays();
1716 if (numArr1 != numArr2) {
1717 std::cerr <<
"Meshes have different numbers of point data" << std::endl;
1718 std::cerr <<
"Mesh 1 has " << numArr1 << std::endl;
1719 std::cerr <<
"Mesh 2 has " << numArr2 << std::endl;
1723 for (
int i = 0; i < numArr1; ++i) {
1724 vtkDataArray *da1 = pd1->GetArray(i);
1725 std::cerr <<
"checking array " << da1->GetName() << std::endl;
1726 vtkDataArray *da2 = pd2->GetArray(pd1->GetArrayName(i));
1730 int numComponent = da1->GetNumberOfComponents();
1732 double *comps1 =
new double[numComponent];
1733 double *comps2 =
new double[numComponent];
1734 da1->GetTuple(j, comps1);
1735 da2->GetTuple(j, comps2);
1736 for (
int k = 0; k < numComponent; ++k) {
1737 da1->GetRange(range, k);
1738 abs_error = std::fabs(comps1[k] - comps2[k]);
1739 double max_val = std::max(std::abs(range[0]), std::abs(range[1]));
1740 rel_error = abs_error / std::max(1.0, max_val);
1741 if (rel_error > tol) {
1742 std::cerr <<
"For point data array " << da1->GetName() << std::endl;
1743 std::cerr <<
"Meshes differ in point data values at point " << j
1744 <<
" component " << k << std::endl;
1745 std::cerr << std::setprecision(15) <<
"Mesh 1 value : " << comps1[k]
1747 std::cerr << std::setprecision(15) <<
"Mesh 2 value : " << comps2[k]
1756 std::cerr <<
"Meshes are the same" << std::endl;
1761 std::vector<nemId_t> rhs)
const {
1762 std::sort(lhs.begin(), lhs.end());
1763 std::sort(rhs.begin(), rhs.end());
1771 vtkSmartPointer<vtkUnstructuredGrid> vtkDataSetNoQuads =
1774 std::vector<std::vector<int>> removedQuadIds;
1777 points->SetNumberOfPoints(this->getDataSet()->GetNumberOfPoints());
1779 for (
int iPoint = 0; iPoint < this->getDataSet()->GetNumberOfPoints();
1781 this->getDataSet()->GetPoint(iPoint, pt);
1782 points->SetPoint(iPoint, pt[0], pt[1], pt[2]);
1784 vtkDataSetNoQuads->SetPoints(points);
1787 for (
int iCell = 0; iCell < this->getDataSet()->GetNumberOfCells(); iCell++) {
1789 if (this->getDataSet()->GetCell(iCell)->GetCellType() == VTK_QUAD) {
1790 vtkSmartPointer<vtkIdList> elmIds =
1791 this->getDataSet()->GetCell(iCell)->GetPointIds();
1792 std::vector<int> elmIdsVec = {
static_cast<int>(elmIds->GetId(0)),
1793 static_cast<int>(elmIds->GetId(1)),
1794 static_cast<int>(elmIds->GetId(2)),
1795 static_cast<int>(elmIds->GetId(3))};
1796 removedQuadIds.push_back(elmIdsVec);
1800 vtkDataSetNoQuads->InsertNextCell(
1801 this->getDataSet()->GetCell(iCell)->GetCellType(),
1802 this->getDataSet()->GetCell(iCell)->GetPointIds());
1807 for (
auto elemItr = removedQuadIds.begin(); elemItr != removedQuadIds.end();
1810 triList1->InsertNextId((*elemItr)[0]);
1811 triList1->InsertNextId((*elemItr)[1]);
1812 triList1->InsertNextId((*elemItr)[2]);
1813 vtkDataSetNoQuads->InsertNextCell(VTK_TRIANGLE, triList1);
1816 triList2->InsertNextId((*elemItr)[0]);
1817 triList2->InsertNextId((*elemItr)[2]);
1818 triList2->InsertNextId((*elemItr)[3]);
1820 vtkDataSetNoQuads->InsertNextCell(VTK_TRIANGLE, triList2);
1823 return Create(vtkDataSetNoQuads,
"removedQuads.vtu");
1827 vtkSmartPointer<vtkDataSetTriangleFilter> triFilter =
1829 triFilter->SetInputData(meshdataSet);
1830 triFilter->Update();
1832 dataSet = triFilter->GetOutput();
1836 bool fromPointArrays) {
1837 std::vector<int> arrayIDs(arrayNames.size());
1838 for (
int i = 0; i < arrayNames.size(); ++i) {
1839 int id = IsArrayName(arrayNames[i], fromPointArrays);
1841 std::cerr <<
"Array " << arrayNames[i]
1842 <<
" not found in set of data arrays." << std::endl;
void setPointDataArray(const std::string &name, const std::vector< std::vector< double >> &data) override
register data to dataSet's point data
std::vector< std::vector< nemId_t > > globalNodeIds
std::vector< std::map< nemId_t, nemId_t > > partToGlobCellMap
virtual void computeSizeField(vtkDataArray *da)=0
static std::unique_ptr< SizeFieldBase > CreateUnique(vtkDataSet *_dataSet, const std::string &method, int arrayID, double _dev_mult, bool _maxIsmin, double _sizeFactor=1.0, int _order=1)
data_type data
Edge/face with sorted point ids (a, b, c, ...) is located at some index i in data[b], with data[b][i].first == [a, c] (for edges, third point id treated as -1).
nemId_t numPoints
number of points in mesh
void refineMesh(const std::string &method, int arrayID, double dev_mult, bool maxIsmin, double edge_scale, const std::string &ofname, bool transferData, double sizeFactor=1., bool constrainBoundary=false)
perform sizefield-based h-refinement.
bool operator()(std::vector< nemId_t > lhs, std::vector< nemId_t > rhs) const
static meshBase * exportGmshToVtk(const std::string &fname)
construct vtkMesh from gmsh msh file (called in Create methods)
static meshBase * exportVolToVtk(const std::string &fname)
construct vtkMesh from netgen vol file (called in Create methods)
void setFileName(const std::string &fname)
set the file name.
static std::vector< std::shared_ptr< meshBase > > partition(const meshBase *mbObj, int numPartitions)
mesh partitioning (with METIS)
vtkSmartPointer< vtkDataSet > dataSet
mesh points, topology and data
vtkSmartPointer< vtkStaticCellLocator > buildStaticCellLocator()
build locators for efficient search operations
static meshBase * exportPntToVtk(const std::string &fname)
construct vtkMesh from netgen vol file (called in Create methods)
static meshBase * exportExoToVtk(const std::string &fname)
construct vtkMesh from exodusII files
std::vector< std::map< nemId_t, nemId_t > > partToGlobNodeMap
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
elementType elmTypeNum(std::string tag)
Convert string to EXODUS element type.
int IsArrayName(const std::string &name, bool pointOrCell=false) const
check for named array in vtk and return its integer id.
void writePatchMap(const std::string &mapFile, const std::map< int, int > &patchMap)
write patch map file for roc prep (trivial identity mapping)
static meshBase * Create(const std::string &fname)
Construct vtkMesh from filename.
void checkMesh(const std::string &ofname) const
<>
void checkMesh(std::ostream &outputStream)
std::vector< std::vector< double > > integrateOverAllCells()
Integrate arrays specified by arrayIDs over all cells.
nemId_t numCells
number of cells in mesh
void setCellDataArray(const std::string &name, const std::vector< std::vector< double >> &data) override
register data to dataSet's cell data
std::vector< int > getArrayIDs(std::vector< std::string > arrayNames, bool fromPointArrays=false)
given array names, return corresponding ids
virtual std::vector< std::vector< double > > getCellVec(nemId_t id) const =0
get vector of coords of cell with id
std::vector< double > getPointCrd(int id) const
std::string trim_fname(const std::string &name, const std::string &ext)
vtkSmartPointer< vtkDataSet > getDataSet() const
get this meshes' dataSet
const std::string & getFileName() const
get the current file name
nemId_t getNumberOfPoints() const
return the number of points
void generateSizeField(const std::string &method, int arrayID, double dev_mlt, bool maxIsmin, double sizeFactor=1.0, int order=1)
generate size field based on method and given a point data array.
vtkIdType id
id in .inp file
sum comparison for vectors representing faces inserted into map
meshBase * convertQuads()
static meshBase * stitchMB(const std::vector< meshBase *> &mbObjs)
stitch together several meshBases
std::shared_ptr< meshBase > mesh
static std::shared_ptr< meshBase > CreateShared(const std::string &fname)
Create shared ptr from fname.
std::vector< vtkIdType > points
points given by id in .inp file
virtual std::vector< std::vector< double > > getVertCrds() const =0
get 3 vecs with x,y and z coords
static std::unique_ptr< meshBase > CreateUnique(const std::string &fname)
create unique ptr from fname
int diffMesh(meshBase *mesh1, meshBase *mesh2)
compares two meshBase classes.
std::vector< int > getElmConn(int id) const
void run(bool transferData, bool bndryConstraint=false)
std::vector< std::vector< double > > integrateOverMesh(const std::vector< int > &arrayIDs)
integrate arrays in arrayIDs over the mesh.
vtkSmartPointer< vtkStaticPointLocator > buildStaticPointLocator()
build thread-safe point locator for efficient search operations
int getNumberOfPoints() const
static meshBase * extractSelectedCells(meshBase *mesh, const std::vector< nemId_t > &cellIds)
extract subset of mesh given list of cell ids and return meshBase obj
nemId_t getNumberOfCells() const
return the number of cells
VTKCellType e2vEMap(elementType et)
Convert EXODUS element type to VTK cell type.
void convertHexToTetVTK(vtkSmartPointer< vtkDataSet > meshdataSet)
Converts given hexahedral VTK dataset into tetrahedral mesh and stores it into dataSet variable...
void write() const override
write the mesh to file named after the private var 'filename'.
virtual std::vector< double > getPoint(nemId_t id) const =0
get point with id
void setSizeFactor(double sf)
void wrnErrMsg(int errCode, const std::string &msg)
Logging method.
void writeCobalt(meshBase *surfWithPatch, const std::string &mapFile, std::ofstream &outputStream)
surfWithPatch must have patchNo array
static std::unique_ptr< GaussCubature > CreateUnique(vtkDataSet *_dataSet)
int getNumberOfCells() const
void writeMSH(std::ofstream &outputStream)
convert to gmsh format without data