29 #define _USE_MATH_DEFINES 34 #include <vtkCell3D.h> 43 #include <Eigen/Geometry> 63 std::cout <<
"rocPack class constructed!" << std::endl;
79 std::cout <<
" - End of process!" << std::endl;
101 std::cout <<
" - End of process!" << std::endl;
127 const double &lowerThreshold) {
145 gmsh::model::add(
"Pack");
146 gmsh::option::setNumber(
"General.NumThreads", 10);
147 gmsh::option::setNumber(
"Geometry.OCCBooleanPreserveNumbering", 1);
148 gmsh::option::setNumber(
"Geometry.OCCParallel", 1);
154 std::cout <<
" - Parsing output file ... " << std::endl;
155 std::ifstream rocOut(
InFile);
156 if (rocOut.is_open()) {
161 std::vector<std::string> rocTokens;
162 std::string line =
findWord(
"boundary");
164 if (rocTokens[6] !=
"periodic") {
165 std::cerr <<
"Please select output file with periodic geometries!" 179 std::string linesOut;
180 std::vector<std::string> myLines;
181 while (std::getline(rocOut, linesOut)) myLines.push_back(linesOut);
184 for (
int i = 0; i < myLines.size(); i++) {
187 if (myLines[i].find(
"setperiodicity") != std::string::npos)
188 if (myLines[i].find(
"true") != std::string::npos)
191 if (myLines[i].find(
"removeboundarypacks") != std::string::npos)
192 if (myLines[i].find(
"true") != std::string::npos)
195 if (myLines[i].find(
"set scaling") != std::string::npos) {
196 std::vector<std::string> glbSclTkns;
212 std::cerr <<
"Periodicity needed if using periodic meshing!" << std::endl
213 <<
"Please enable SetPeriodicity option to" 214 <<
" get 3D periodic mesh" << std::endl;
221 for (
int i = 0; i < myLines.size(); i++) {
222 if (myLines[i].find(
"#import") != std::string::npos ||
223 myLines[i].find(
"import") == std::string::npos) {
225 }
else if (myLines[i].find(
"import") != std::string::npos ||
226 myLines[i].find(
"#import") == std::string::npos) {
228 std::vector<std::string> importStr;
237 verts.resize(nCrystals);
238 faces.resize(nCrystals);
239 for (
int i = 0; i < nCrystals; i++) {
241 verts[i] = getData->getVertices();
242 faces[i] = getData->getFaces();
248 for (
int i = 0; i < myLines.size(); i++) {
249 if (myLines[i].find(
"shape ") != std::string::npos) {
250 std::vector<std::string> baseShapes;
255 if (baseShapes[3] ==
"cylinder") {
261 if (baseShapes[3] ==
"ellipsoid") {
273 std::cout <<
" !!Warning!!" << std::endl
274 <<
" This geometry will not be periodic due to presence of " 275 <<
"Ellipsoid shapes!" << std::endl
276 <<
" Ellipsoid shapes cannot be made periodic as of now!" 283 for (
int i = 0; i < myLines.size(); i++) {
284 if (myLines[i].find(
"translate") != std::string::npos) numPacks++;
285 if (myLines[i].find(
"translate") != std::string::npos && iter == 0)
299 std::string pckNameStr =
" ";
300 std::string translateStr =
"<,,>";
301 std::string rotateStr =
"<,,>";
302 std::string scaleStr =
" ";
304 std::vector<double> udfTranslate;
305 udfTranslate.resize(3);
306 udfTranslate[0] =
xUDF;
307 udfTranslate[1] =
yUDF;
308 udfTranslate[2] =
zUDF;
310 for (
int i = iter; i < myLines.size(); i++) {
313 std::vector<std::string> pckNmDataTokens;
314 pckNmDataTokens.resize(2);
315 std::vector<std::string> trnsltDataTokens;
316 trnsltDataTokens.resize(4);
317 std::vector<std::string> rttDataTokens;
318 rttDataTokens.resize(7);
319 std::vector<std::string> scaleDataTokens;
320 scaleDataTokens.resize(8);
327 trnsltDataTokens =
getShapeData(i + 1, translateStr, myLines);
330 for (
int j = 0; j < 3; j++)
336 for (
int j = 0; j < 3; j++)
342 trnsltDataTokens.clear();
345 rttDataTokens =
getShapeData(i + 2, rotateStr, myLines);
348 for (
int j = 0; j < 4; j++)
353 for (
int j = 0; j < 4; j++)
358 rttDataTokens.clear();
360 scaleDataTokens =
getShapeData(i + 3, scaleStr, myLines);
372 scaleDataTokens.clear();
379 std::cerr <<
"Cannot open/find " <<
InFile <<
" file!" << std::endl;
386 std::cout <<
" - Creating pack geometries ... " << std::endl;
434 gmsh::model::occ::synchronize();
437 gmsh::model::geo::synchronize();
446 std::vector<std::pair<int, int>> tagsInsidePacks;
447 gmsh::model::getEntities(tagsInsidePacks, 3);
450 std::cout <<
" - Ensuring periodicity of geometry ..." << std::endl;
452 gmsh::model::occ::synchronize();
457 std::cout <<
" - Writing triangulated surface files ..." << std::endl;
459 std::vector<std::pair<int, int>> tagsPts;
460 gmsh::model::getEntities(tagsPts, 0);
461 if (
meshSz != -1) gmsh::model::mesh::setSize(tagsPts,
meshSz);
463 gmsh::model::mesh::generate(2);
464 for (
int i = 0; i <
refineIter; i++) gmsh::model::mesh::refine();
465 gmsh::model::mesh::removeDuplicateNodes();
467 if (
OutFile.find(
".stl") != std::string::npos)
469 else if (
OutFile.find(
".vtu") != std::string::npos ||
470 OutFile.find(
".vtk") != std::string::npos) {
471 size_t pos = std::string::npos;
472 while ((pos =
OutFile.find(
".vtu")) != std::string::npos) {
475 while ((pos =
OutFile.find(
".vtk")) != std::string::npos) {
479 }
else if (
OutFile.find(
".msh") != std::string::npos) {
486 size_t lastindex =
OutFile.find_last_of(
".");
487 std::string rawname =
OutFile.substr(0, lastindex);
488 std::string stlFile = rawname +
".stl";
489 std::string vtkFile = rawname +
".msh";
490 std::string mshFile = rawname +
".msh";
499 std::cout <<
" - Writing Periodic mesh files ..." << std::endl;
501 std::vector<std::pair<int, int>> tagsPts;
502 gmsh::model::getEntities(tagsPts, 0);
504 if (
meshSz != -1) gmsh::model::mesh::setSize(tagsPts,
meshSz);
507 gmsh::option::setNumber(
"Mesh.StlOneSolidPerSurface", 2);
510 gmsh::option::setNumber(
"Mesh.SaveGroupsOfNodes", 1);
511 gmsh::model::mesh::generate(3);
513 for (
int i = 0; i <
refineIter; i++) gmsh::model::mesh::refine();
514 gmsh::model::mesh::removeDuplicateNodes();
516 gmsh::option::getNumber(
"Mesh.NbNodes", np);
517 nptsMsh =
static_cast<int>(np);
519 if (
OutFile.find(
".stl") != std::string::npos)
521 else if (
OutFile.find(
".vtu") != std::string::npos ||
522 OutFile.find(
".vtk") != std::string::npos) {
523 size_t pos = std::string::npos;
524 while ((pos =
OutFile.find(
".vtu")) != std::string::npos) {
527 while ((pos =
OutFile.find(
".vtk")) != std::string::npos) {
531 }
else if (
OutFile.find(
".msh") != std::string::npos) {
541 size_t lastindex =
OutFile.find_last_of(
".");
542 std::string rawname =
OutFile.substr(0, lastindex);
543 std::string stlFile = rawname +
".stl";
544 std::string vtkFile = rawname +
".msh";
545 std::string mshFile = rawname +
".msh";
555 gmsh::write(writeFile);
560 size_t lastindex = writeFile.find_last_of(
".");
561 std::string rawname = writeFile.substr(0, lastindex);
562 rawname = rawname +
"_oldMSH.msh";
563 gmsh::option::setNumber(
"Mesh.MshFileVersion", 2.2);
573 gmsh::write(writeFile);
577 if (rmbPacks ==
false) {
585 std::vector<double> xTranslate;
586 std::vector<double> yTranslate;
587 std::vector<double> zTranslate;
589 xTranslate.push_back(
Xdim);
590 yTranslate.push_back(0);
591 zTranslate.push_back(0);
592 xTranslate.push_back(
Xdim);
593 yTranslate.push_back(0);
594 zTranslate.push_back(
Zdim);
595 xTranslate.push_back(
Xdim);
596 yTranslate.push_back(0);
597 zTranslate.push_back(-
Zdim);
599 xTranslate.push_back(-
Xdim);
600 yTranslate.push_back(0);
601 zTranslate.push_back(0);
602 xTranslate.push_back(-
Xdim);
603 yTranslate.push_back(0);
604 zTranslate.push_back(
Zdim);
605 xTranslate.push_back(-
Xdim);
606 yTranslate.push_back(0);
607 zTranslate.push_back(-
Zdim);
609 xTranslate.push_back(0);
610 yTranslate.push_back(
Ydim);
611 zTranslate.push_back(0);
612 xTranslate.push_back(0);
613 yTranslate.push_back(
Ydim);
614 zTranslate.push_back(
Zdim);
615 xTranslate.push_back(0);
616 yTranslate.push_back(
Ydim);
617 zTranslate.push_back(-
Zdim);
619 xTranslate.push_back(0);
620 yTranslate.push_back(-
Ydim);
621 zTranslate.push_back(0);
622 xTranslate.push_back(0);
623 yTranslate.push_back(-
Ydim);
624 zTranslate.push_back(
Zdim);
625 xTranslate.push_back(0);
626 yTranslate.push_back(-
Ydim);
627 zTranslate.push_back(-
Zdim);
629 xTranslate.push_back(
Xdim);
630 yTranslate.push_back(
Ydim);
631 zTranslate.push_back(0);
632 xTranslate.push_back(
Xdim);
633 yTranslate.push_back(
Ydim);
634 zTranslate.push_back(
Zdim);
635 xTranslate.push_back(
Xdim);
636 yTranslate.push_back(
Ydim);
637 zTranslate.push_back(-
Zdim);
639 xTranslate.push_back(
Xdim);
640 yTranslate.push_back(-
Ydim);
641 zTranslate.push_back(0);
642 xTranslate.push_back(
Xdim);
643 yTranslate.push_back(-
Ydim);
644 zTranslate.push_back(
Zdim);
645 xTranslate.push_back(
Xdim);
646 yTranslate.push_back(-
Ydim);
647 zTranslate.push_back(-
Zdim);
649 xTranslate.push_back(-
Xdim);
650 yTranslate.push_back(
Ydim);
651 zTranslate.push_back(0);
652 xTranslate.push_back(-
Xdim);
653 yTranslate.push_back(
Ydim);
654 zTranslate.push_back(
Zdim);
655 xTranslate.push_back(-
Xdim);
656 yTranslate.push_back(
Ydim);
657 zTranslate.push_back(-
Zdim);
659 xTranslate.push_back(-
Xdim);
660 yTranslate.push_back(-
Ydim);
661 zTranslate.push_back(0);
662 xTranslate.push_back(-
Xdim);
663 yTranslate.push_back(-
Ydim);
664 zTranslate.push_back(
Zdim);
665 xTranslate.push_back(-
Xdim);
666 yTranslate.push_back(-
Ydim);
667 zTranslate.push_back(-
Zdim);
669 xTranslate.push_back(0);
670 yTranslate.push_back(0);
671 zTranslate.push_back(
Zdim);
672 xTranslate.push_back(0);
673 yTranslate.push_back(0);
674 zTranslate.push_back(-
Zdim);
971 std::vector<int> indexVols;
972 std::vector<int> indexShapes;
979 indexShapes.push_back(itrMp->second);
980 indexVols.push_back(g);
985 std::vector<int> tmpVec;
989 tmpVec.push_back(i + 1);
995 std::cerr <<
" Progress --> [0%";
997 for (
int h = 0; h < 26; h++) {
998 std::vector<std::pair<int, int>> tagsCopy;
1000 gmsh::model::occ::translate(tagsCopy, xTranslate[h], yTranslate[h],
1005 for (
int g = 0; g < indexVols.size(); g++)
1014 std::cerr.precision(3);
1015 std::cerr <<
".." << 10.7142857 * (ptg) <<
"%";
1019 gmsh::model::occ::synchronize();
1022 std::vector<std::pair<int, int>> tagsPacks;
1023 std::vector<std::pair<int, int>> outBoolean;
1024 std::vector<std::vector<std::pair<int, int>>> outBoolMap;
1025 gmsh::model::getEntities(tagsPacks, 3);
1026 std::vector<std::pair<int, int>> tagsBox;
1029 tagsBox.push_back(std::make_pair(3, tmpTag));
1032 gmsh::model::occ::intersect(tagsPacks, tagsBox, outBoolean, outBoolMap);
1033 std::cout <<
"..100%]" << std::endl;
1035 gmsh::model::occ::synchronize();
1038 for (
int mp = 0; mp < outBoolean.size(); mp++) {
1045 if (itrMp->second == 1)
1047 if (itrMp->second == 2)
1051 if (itrMp->second == 5)
1059 for (
int k = 0; k < tmpVec.size(); k++) {
1060 std::vector<int> oneVols;
1061 for (
int j = 0; j < outBoolean.size(); j++) {
1063 oneVols.push_back(outBoolean[j].second);
1071 std::cout <<
" - Mapping Periodic Surfaces" << std::endl;
1081 std::ifstream input(
InFile);
1083 while (std::getline(input, line))
1084 if (line.find(word) == 0)
return line;
1089 const int &iter,
const std::string &a,
const std::vector<std::string> &L) {
1101 gmsh::model::occ::synchronize();
1105 std::vector<int> pts;
1106 std::vector<int> arcs;
1107 std::vector<int> loops;
1108 std::vector<int> surfs;
1109 std::vector<int> tmpCurveLoop;
1110 std::vector<std::vector<double>> elVerts;
1111 std::vector<std::vector<double>> rotatedVerts;
1113 rotatedVerts.resize(7);
1120 elVerts[0].resize(3);
1124 elVerts[1].resize(3);
1128 elVerts[2].resize(3);
1132 elVerts[3].resize(3);
1136 elVerts[4].resize(3);
1137 elVerts[4][0] = -
scaleOfPack[n] * ellipsoidRad[0];
1140 elVerts[5].resize(3);
1142 elVerts[5][1] = -
scaleOfPack[n] * ellipsoidRad[1];
1144 elVerts[6].resize(3);
1147 elVerts[6][2] = -
scaleOfPack[n] * ellipsoidRad[2];
1151 for (
int i = 0; i < 7; i++)
1156 for (
int i = 0; i < rotatedVerts.size(); i++)
1158 gmsh::model::geo::addPoint(rotatedVerts[i][0] +
translateParams[n][0],
1163 arcs[0] = gmsh::model::geo::addEllipseArc(pts[1], pts[0], pts[6], pts[6]);
1164 arcs[1] = gmsh::model::geo::addEllipseArc(pts[6], pts[0], pts[4], pts[4]);
1165 arcs[2] = gmsh::model::geo::addEllipseArc(pts[4], pts[0], pts[3], pts[3]);
1166 arcs[3] = gmsh::model::geo::addEllipseArc(pts[3], pts[0], pts[1], pts[1]);
1167 arcs[4] = gmsh::model::geo::addEllipseArc(pts[1], pts[0], pts[2], pts[2]);
1168 arcs[5] = gmsh::model::geo::addEllipseArc(pts[2], pts[0], pts[4], pts[4]);
1169 arcs[6] = gmsh::model::geo::addEllipseArc(pts[4], pts[0], pts[5], pts[5]);
1170 arcs[7] = gmsh::model::geo::addEllipseArc(pts[5], pts[0], pts[1], pts[1]);
1171 arcs[8] = gmsh::model::geo::addEllipseArc(pts[6], pts[0], pts[2], pts[2]);
1172 arcs[9] = gmsh::model::geo::addEllipseArc(pts[2], pts[0], pts[3], pts[3]);
1173 arcs[10] = gmsh::model::geo::addEllipseArc(pts[3], pts[0], pts[5], pts[5]);
1174 arcs[11] = gmsh::model::geo::addEllipseArc(pts[5], pts[0], pts[6], pts[6]);
1177 tmpCurveLoop.push_back(arcs[4]);
1178 tmpCurveLoop.push_back(arcs[9]);
1179 tmpCurveLoop.push_back(arcs[3]);
1180 loops[0] = gmsh::model::geo::addCurveLoop(tmpCurveLoop);
1181 tmpCurveLoop.clear();
1182 tmpCurveLoop.push_back(arcs[8]);
1183 tmpCurveLoop.push_back(-arcs[4]);
1184 tmpCurveLoop.push_back(arcs[0]);
1185 loops[1] = gmsh::model::geo::addCurveLoop(tmpCurveLoop);
1186 tmpCurveLoop.clear();
1187 tmpCurveLoop.push_back(-arcs[9]);
1188 tmpCurveLoop.push_back(arcs[5]);
1189 tmpCurveLoop.push_back(arcs[2]);
1190 loops[2] = gmsh::model::geo::addCurveLoop(tmpCurveLoop);
1191 tmpCurveLoop.clear();
1192 tmpCurveLoop.push_back(-arcs[5]);
1193 tmpCurveLoop.push_back(-arcs[8]);
1194 tmpCurveLoop.push_back(arcs[1]);
1195 loops[3] = gmsh::model::geo::addCurveLoop(tmpCurveLoop);
1196 tmpCurveLoop.clear();
1197 tmpCurveLoop.push_back(arcs[7]);
1198 tmpCurveLoop.push_back(-arcs[3]);
1199 tmpCurveLoop.push_back(arcs[10]);
1200 loops[4] = gmsh::model::geo::addCurveLoop(tmpCurveLoop);
1201 tmpCurveLoop.clear();
1202 tmpCurveLoop.push_back(arcs[11]);
1203 tmpCurveLoop.push_back(-arcs[7]);
1204 tmpCurveLoop.push_back(-arcs[0]);
1205 loops[5] = gmsh::model::geo::addCurveLoop(tmpCurveLoop);
1206 tmpCurveLoop.clear();
1207 tmpCurveLoop.push_back(-arcs[10]);
1208 tmpCurveLoop.push_back(-arcs[2]);
1209 tmpCurveLoop.push_back(arcs[6]);
1210 loops[6] = gmsh::model::geo::addCurveLoop(tmpCurveLoop);
1211 tmpCurveLoop.clear();
1212 tmpCurveLoop.push_back(-arcs[1]);
1213 tmpCurveLoop.push_back(-arcs[6]);
1214 tmpCurveLoop.push_back(-arcs[11]);
1215 loops[7] = gmsh::model::geo::addCurveLoop(tmpCurveLoop);
1216 tmpCurveLoop.clear();
1219 tmpCurveLoop.push_back(loops[0]);
1220 surfs[0] = gmsh::model::geo::addSurfaceFilling(tmpCurveLoop);
1221 tmpCurveLoop.clear();
1222 tmpCurveLoop.push_back(loops[1]);
1223 surfs[1] = gmsh::model::geo::addSurfaceFilling(tmpCurveLoop);
1224 tmpCurveLoop.clear();
1225 tmpCurveLoop.push_back(loops[2]);
1226 surfs[2] = gmsh::model::geo::addSurfaceFilling(tmpCurveLoop);
1227 tmpCurveLoop.clear();
1228 tmpCurveLoop.push_back(loops[3]);
1229 surfs[3] = gmsh::model::geo::addSurfaceFilling(tmpCurveLoop);
1230 tmpCurveLoop.clear();
1231 tmpCurveLoop.push_back(loops[4]);
1232 surfs[4] = gmsh::model::geo::addSurfaceFilling(tmpCurveLoop);
1233 tmpCurveLoop.clear();
1234 tmpCurveLoop.push_back(loops[5]);
1235 surfs[5] = gmsh::model::geo::addSurfaceFilling(tmpCurveLoop);
1236 tmpCurveLoop.clear();
1237 tmpCurveLoop.push_back(loops[6]);
1238 surfs[6] = gmsh::model::geo::addSurfaceFilling(tmpCurveLoop);
1239 tmpCurveLoop.clear();
1240 tmpCurveLoop.push_back(loops[7]);
1241 surfs[7] = gmsh::model::geo::addSurfaceFilling(tmpCurveLoop);
1242 tmpCurveLoop.clear();
1245 tmpCurveLoop.push_back(surfs[0]);
1246 tmpCurveLoop.push_back(surfs[1]);
1247 tmpCurveLoop.push_back(surfs[2]);
1248 tmpCurveLoop.push_back(surfs[3]);
1249 tmpCurveLoop.push_back(surfs[4]);
1250 tmpCurveLoop.push_back(surfs[5]);
1251 tmpCurveLoop.push_back(surfs[6]);
1252 tmpCurveLoop.push_back(surfs[7]);
1253 int surfLoop = gmsh::model::geo::addSurfaceLoop(tmpCurveLoop);
1254 tmpCurveLoop.clear();
1257 tmpCurveLoop.push_back(surfLoop);
1258 int newVol = gmsh::model::geo::addVolume(tmpCurveLoop);
1259 gmsh::model::geo::synchronize();
1263 gmsh::model::geo::synchronize();
1273 std::vector<double> cylCenter = std::vector<double>(3);
1279 std::vector<double> translation_axis = std::vector<double>(3);
1280 translation_axis[0] = 0;
1282 translation_axis[2] = 0;
1285 std::vector<std::vector<double>> cylVertices;
1286 cylVertices.resize(4);
1287 cylVertices[0].resize(3);
1288 cylVertices[1].resize(3);
1289 cylVertices[2].resize(3);
1290 cylVertices[3].resize(3);
1292 cylVertices[0][0] = 0;
1295 cylVertices[1][0] = 0 +
cylParams[0] * scaleOfPack[n];
1296 cylVertices[1][1] = 0 - (
cylParams[1] / 2) * scaleOfPack[n];
1297 cylVertices[1][2] = 0;
1298 cylVertices[2][0] = 0;
1299 cylVertices[2][1] = 0 - (
cylParams[1] / 2) * scaleOfPack[n];
1300 cylVertices[2][2] = 0 -
cylParams[0] * scaleOfPack[n];
1301 cylVertices[3][0] = 0 -
cylParams[0] * scaleOfPack[n];
1302 cylVertices[3][1] = 0 - (
cylParams[1] / 2) * scaleOfPack[n];
1303 cylVertices[3][2] = 0;
1308 std::vector<double> rotatedCylCenter;
1309 std::vector<double> rotatedTranslationAxis;
1310 std::vector<std::vector<double>> rotatedCylVertices;
1311 rotatedCylVertices.resize(4);
1320 for (
int i = 0; i < 4; i++)
1324 std::vector<int> pts = std::vector<int>(5);
1327 gmsh::model::occ::addPoint(rotatedCylCenter[0] +
translateParams[n][0],
1331 for (
int i = 0; i < rotatedCylVertices.size(); i++)
1332 pts[i + 1] = gmsh::model::occ::addPoint(
1337 std::vector<int> arcs = std::vector<int>(4);
1338 arcs[0] = gmsh::model::occ::addCircleArc(pts[1], pts[0], pts[2]);
1339 arcs[1] = gmsh::model::occ::addCircleArc(pts[2], pts[0], pts[3]);
1340 arcs[2] = gmsh::model::occ::addCircleArc(pts[3], pts[0], pts[4]);
1341 arcs[3] = gmsh::model::occ::addCircleArc(pts[4], pts[0], pts[1]);
1343 std::vector<int> curves = std::vector<int>(4);
1344 curves[0] = arcs[0];
1345 curves[1] = arcs[1];
1346 curves[2] = arcs[2];
1347 curves[3] = arcs[3];
1348 int loop = gmsh::model::occ::addCurveLoop(curves);
1350 std::vector<int> loops = std::vector<int>(1);
1352 int surf = gmsh::model::occ::addPlaneSurface(loops);
1354 gmsh::model::occ::synchronize();
1355 std::vector<std::pair<int, int>> tagsSurfs;
1356 std::vector<std::pair<int, int>> outVols;
1357 tagsSurfs.push_back(std::make_pair(2, surf));
1359 gmsh::model::occ::extrude(tagsSurfs, rotatedTranslationAxis[0],
1360 rotatedTranslationAxis[1],
1361 rotatedTranslationAxis[2], outVols);
1363 for (
int i = 0; i < outVols.size(); i++)
1364 if (outVols[i].first == 3)
1367 gmsh::model::occ::synchronize();
1371 std::vector<std::vector<double>> scaledVerts;
1372 scaledVerts.resize(
verts[index].size());
1375 for (
int i = 0; i <
verts[index].size(); i++) {
1376 scaledVerts[i].resize(3);
1377 for (
int j = 0; j <
verts[index][i].size(); j++)
1383 std::vector<std::vector<double>> rotatedVerts;
1384 rotatedVerts.resize(
verts[index].size());
1386 for (
int i = 0; i <
verts[index].size(); i++)
1390 for (
int i = 0; i < rotatedVerts.size(); i++)
1391 for (
int j = 0; j < rotatedVerts[i].size(); j++)
1395 std::vector<int> pts;
1396 pts.resize(rotatedVerts.size());
1397 for (
int i = 0; i < rotatedVerts.size(); i++) {
1398 pts[i] = gmsh::model::occ::addPoint(rotatedVerts[i][0], rotatedVerts[i][1],
1399 rotatedVerts[i][2]);
1402 std::vector<std::vector<int>> lines;
1403 lines.resize(
faces[index].size());
1404 std::vector<int> surfs;
1405 surfs.resize(
faces[index].size());
1406 std::vector<int> lineLoops;
1407 lineLoops.resize(
faces[index].size());
1409 std::map<std::pair<int, int>,
int> lineMap;
1411 for (
int i = 0; i <
faces[index].size(); i++) {
1412 lines[i].resize(
faces[index][i].size());
1413 for (
int j = 0; j <
faces[index][i].size(); j++) {
1415 std::map<std::pair<int, int>,
int>::iterator it;
1416 int a = pts[
faces[index][i][j]];
1417 int b = pts[faces[index][i][(j + 1) % faces[index][i].size()]];
1419 it = lineMap.find(std::make_pair(a, b));
1421 if (it == lineMap.end()) it = lineMap.find(std::make_pair(b, a));
1423 if (it == lineMap.end()) {
1424 lines[i][j] = gmsh::model::occ::addLine(a, b);
1425 lineMap.insert(std::make_pair(std::make_pair(a, b), lines[i][j]));
1427 lines[i][j] = it->second;
1431 lineLoops[i] = gmsh::model::occ::addCurveLoop(lines[i]);
1433 std::vector<int> tagsSurfFill = std::vector<int>(1);
1434 tagsSurfFill[0] = lineLoops[i];
1436 surfs[i] = gmsh::model::occ::addSurfaceFilling(lineLoops[i]);
1438 surfs[i] = gmsh::model::occ::addPlaneSurface(tagsSurfFill);
1442 int surfLoop = gmsh::model::occ::addSurfaceLoop(surfs);
1445 std::vector<int> surfLoopTags = std::vector<int>(1);
1446 surfLoopTags[0] = surfLoop;
1447 int newVol = gmsh::model::occ::addVolume(surfLoopTags);
1457 gmsh::model::occ::synchronize();
1462 for (
int k = 0; k <
verts.size(); k++) {
1463 double maxNorm = 0.0;
1464 for (
int i = 0; i <
verts[k].size(); i++) {
1465 double norm = sqrt(pow(
verts[k][i][0], 2) + pow(
verts[k][i][1], 2) +
1466 pow(
verts[k][i][2], 2));
1467 if (norm > maxNorm) maxNorm = norm;
1470 for (
int i = 0; i <
verts[k].size(); i++) {
1480 std::vector<std::pair<int, int>> tagsWithinBoundary;
1481 std::vector<std::pair<int, int>> tagsAll;
1483 std::vector<int> insidePacks;
1484 std::vector<int> allPacks;
1485 std::vector<int> bndryPackVols;
1489 boxPt[2] +
Zdim, tagsWithinBoundary, 3);
1491 gmsh::model::getEntities(tagsAll, 3);
1493 for (
auto iter : tagsWithinBoundary) insidePacks.push_back(iter.second);
1495 for (
auto iter2 : tagsAll) allPacks.push_back(iter2.second);
1497 for (
int i = 0; i < allPacks.size(); i++) {
1499 for (
int j = 0; j < insidePacks.size(); j++)
1500 if (allPacks[i] == insidePacks[j]) {
1505 if (ht == 0) bndryPackVols.push_back(allPacks[i]);
1510 std::cerr <<
"There are no volumes left inside the Box!" << std::endl;
1511 std::cerr <<
"Try increasing the domain size or pack density!" 1513 std::cerr <<
"Or disable physical group options" << std::endl;
1519 for (
int i = 0; i < bndryPackVols.size(); i++)
1520 bndryPackTags.push_back(std::make_pair(3, bndryPackVols[i]));
1524 const std::vector<double> &v) {
1525 Eigen::VectorXd InputVec(3);
1526 Eigen::VectorXd RotatedVec(3);
1527 std::vector<double> returnVec = std::vector<double>(3);
1533 Eigen::Quaternion<double> Quaternion(q.
w, q.
x, q.
y, q.
z);
1535 RotatedVec = Quaternion._transformVector(InputVec);
1537 returnVec[0] = RotatedVec[0];
1538 returnVec[1] = RotatedVec[1];
1539 returnVec[2] = RotatedVec[2];
1546 double angle = r[3] * 3.141592653589 / 180;
1548 q.
x = r[0] * sin(angle / 2);
1549 q.
y = r[1] * sin(angle / 2);
1550 q.
z = r[2] * sin(angle / 2);
1551 q.
w = cos(angle / 2);
1557 const std::vector<std::pair<int, int>> &prevTags) {
1559 gmsh::model::occ::synchronize();
1560 std::vector<std::pair<int, int>> tagsBox2;
1563 tagsBox2.push_back(std::make_pair(3, tmpTag2));
1564 std::vector<std::pair<int, int>> outBoolean2;
1565 std::vector<std::vector<std::pair<int, int>>> outBoolMap2;
1566 gmsh::model::occ::fragment(tagsBox2, prevTags, outBoolean2, outBoolMap2);
1567 gmsh::model::occ::synchronize();
1571 std::vector<std::pair<int, int>> tagstmpVOL;
1572 tagstmpVOL.push_back(std::make_pair(3, tmpTag2));
1573 std::vector<std::pair<int, int>> tagsAllsurfs;
1575 gmsh::model::getBoundary(tagstmpVOL, tagsAllsurfs);
1577 int totalSurfsinBox = tagsAllsurfs.size() - 1;
1580 std::vector<int> surfTagUp;
1581 surfTagUp.push_back(tagsAllsurfs[totalSurfsinBox - 2].second);
1582 int Up = gmsh::model::addPhysicalGroup(2, surfTagUp);
1583 gmsh::model::setPhysicalName(2, Up,
"Up");
1585 std::vector<int> surfTagDown;
1586 surfTagDown.push_back(tagsAllsurfs[totalSurfsinBox - 4].second);
1587 int Down = gmsh::model::addPhysicalGroup(2, surfTagDown);
1588 gmsh::model::setPhysicalName(2, Down,
"Down");
1590 std::vector<int> surfTagLeft;
1591 surfTagLeft.push_back(tagsAllsurfs[totalSurfsinBox - 5].second);
1592 int Left = gmsh::model::addPhysicalGroup(2, surfTagLeft);
1593 gmsh::model::setPhysicalName(2, Left,
"Left");
1595 std::vector<int> surfTagRight;
1596 surfTagRight.push_back(tagsAllsurfs[totalSurfsinBox].second);
1597 int Right = gmsh::model::addPhysicalGroup(2, surfTagRight);
1598 gmsh::model::setPhysicalName(2, Right,
"Right");
1600 std::vector<int> surfTagFront;
1601 surfTagFront.push_back(tagsAllsurfs[totalSurfsinBox - 3].second);
1602 int Front = gmsh::model::addPhysicalGroup(2, surfTagFront);
1603 gmsh::model::setPhysicalName(2, Front,
"Front");
1605 std::vector<int> surfTagBack;
1606 surfTagBack.push_back(tagsAllsurfs[totalSurfsinBox - 1].second);
1607 int Back = gmsh::model::addPhysicalGroup(2, surfTagBack);
1608 gmsh::model::setPhysicalName(2, Back,
"Back");
1614 std::cerr <<
"Please select only one option for physical group" 1622 std::vector<int> vecTags;
1623 vecTags.push_back(tmpTag2);
1628 std::vector<int> newTags;
1629 std::string name =
"Vol" + std::to_string(i);
1634 int newGrp = gmsh::model::addPhysicalGroup(3, newTags);
1636 gmsh::model::setPhysicalName(3, newGrp, name);
1640 std::vector<int> vecTags;
1641 vecTags.push_back(tmpTag2);
1645 std::vector<std::pair<int, int>> tagsAll;
1646 gmsh::model::getEntities(tagsAll, 3);
1647 std::vector<int> newTags;
1649 for (
int i = 0; i < tagsAll.size(); i++) {
1650 if (tagsAll[i].second == tmpTag2) {
1652 newTags.push_back(tagsAll[i].second);
1656 packGrp = gmsh::model::addPhysicalGroup(3, newTags);
1657 gmsh::model::setPhysicalName(3,
packGrp,
"MicroStructures");
1660 std::vector<int> vecTags;
1661 vecTags.push_back(tmpTag2);
1669 gmsh::model::setPhysicalName(3, newGrp,
"Spheres");
1676 gmsh::model::setPhysicalName(3, newGrp,
"Cylinders");
1683 gmsh::model::setPhysicalName(3, newGrp,
"Ellipsoids");
1690 gmsh::model::setPhysicalName(3, newGrp,
"PETN");
1698 gmsh::model::setPhysicalName(3, newGrp,
"Icosidodecahedron");
1705 gmsh::model::setPhysicalName(3, newGrp,
"HMX");
1711 std::vector<std::pair<int, int>> tagsAll;
1712 gmsh::model::getEntities(tagsAll, 3);
1714 for (
int i = 0; i < tagsAll.size(); i++) {
1715 if (tagsAll[i].second == tmpTag2) {
1726 std::vector<std::pair<int, int>> entityLeft;
1727 gmsh::model::getEntitiesInBoundingBox(
1732 std::vector<std::pair<int, int>> entityRight;
1733 gmsh::model::getEntitiesInBoundingBox(
Xdim +
boxPt[0] - tol,
boxPt[1] - tol,
1739 std::vector<std::pair<int, int>> entityUp;
1740 gmsh::model::getEntitiesInBoundingBox(
boxPt[0] - tol,
Ydim +
boxPt[1] - tol,
1746 std::vector<std::pair<int, int>> entityDown;
1747 gmsh::model::getEntitiesInBoundingBox(
1752 std::vector<std::pair<int, int>> entityBack;
1753 gmsh::model::getEntitiesInBoundingBox(
1758 std::vector<std::pair<int, int>> entityFront;
1759 gmsh::model::getEntitiesInBoundingBox(
1765 std::vector<std::vector<std::pair<int, int>>> vertsLeft =
1767 std::vector<std::vector<std::pair<int, int>>> vertsRight =
1769 std::vector<std::vector<std::pair<int, int>>> vertsUp =
1771 std::vector<std::vector<std::pair<int, int>>> vertsDown =
1773 std::vector<std::vector<std::pair<int, int>>> vertsFront =
1775 std::vector<std::vector<std::pair<int, int>>> vertsBack =
1779 std::vector<std::pair<int, int>> periodicSurfsX;
1780 std::vector<std::pair<int, int>> periodicSurfsY;
1781 std::vector<std::pair<int, int>> periodicSurfsZ;
1788 for (
int i = 0; i < periodicSurfsX.size(); i++) {
1789 slaveX.push_back(periodicSurfsX[i].first);
1790 MasterX.push_back(periodicSurfsX[i].second);
1793 for (
int i = 0; i < periodicSurfsY.size(); i++) {
1794 slaveY.push_back(periodicSurfsY[i].first);
1795 MasterY.push_back(periodicSurfsY[i].second);
1798 for (
int i = 0; i < periodicSurfsZ.size(); i++) {
1799 slaveZ.push_back(periodicSurfsZ[i].first);
1800 MasterZ.push_back(periodicSurfsZ[i].second);
1803 std::vector<std::vector<double>> affineTransform;
1804 affineTransform.resize(3);
1805 affineTransform[0].resize(16);
1806 affineTransform[1].resize(16);
1807 affineTransform[2].resize(16);
1808 double xT = -1 *
Xdim;
1809 double yT = -1 *
Ydim;
1810 double zT = -1 *
Zdim;
1812 affineTransform[0][0] = 1;
1813 affineTransform[0][1] = 0;
1814 affineTransform[0][2] = 0;
1815 affineTransform[0][3] = xT;
1816 affineTransform[0][4] = 0;
1817 affineTransform[0][5] = 1;
1818 affineTransform[0][6] = 0;
1819 affineTransform[0][7] = 0;
1820 affineTransform[0][8] = 0;
1821 affineTransform[0][9] = 0;
1822 affineTransform[0][10] = 1;
1823 affineTransform[0][11] = 0;
1824 affineTransform[0][12] = 0;
1825 affineTransform[0][13] = 0;
1826 affineTransform[0][14] = 0;
1827 affineTransform[0][15] = 1;
1829 affineTransform[1][0] = 1;
1830 affineTransform[1][1] = 0;
1831 affineTransform[1][2] = 0;
1832 affineTransform[1][3] = 0;
1833 affineTransform[1][4] = 0;
1834 affineTransform[1][5] = 1;
1835 affineTransform[1][6] = 0;
1836 affineTransform[1][7] = yT;
1837 affineTransform[1][8] = 0;
1838 affineTransform[1][9] = 0;
1839 affineTransform[1][10] = 1;
1840 affineTransform[1][11] = 0;
1841 affineTransform[1][12] = 0;
1842 affineTransform[1][13] = 0;
1843 affineTransform[1][14] = 0;
1844 affineTransform[1][15] = 1;
1846 affineTransform[2][0] = 1;
1847 affineTransform[2][1] = 0;
1848 affineTransform[2][2] = 0;
1849 affineTransform[2][3] = 0;
1850 affineTransform[2][4] = 0;
1851 affineTransform[2][5] = 1;
1852 affineTransform[2][6] = 0;
1853 affineTransform[2][7] = 0;
1854 affineTransform[2][8] = 0;
1855 affineTransform[2][9] = 0;
1856 affineTransform[2][10] = 1;
1857 affineTransform[2][11] = zT;
1858 affineTransform[2][12] = 0;
1859 affineTransform[2][13] = 0;
1860 affineTransform[2][14] = 0;
1861 affineTransform[2][15] = 1;
1863 gmsh::model::mesh::setPeriodic(2,
slaveX,
MasterX, affineTransform[0]);
1864 gmsh::model::mesh::setPeriodic(2,
slaveY,
MasterY, affineTransform[1]);
1865 gmsh::model::mesh::setPeriodic(2,
slaveZ,
MasterZ, affineTransform[2]);
1866 gmsh::model::occ::synchronize();
1870 std::vector<std::pair<int, int>>
surfaces) {
1871 std::vector<std::vector<std::pair<int, int>>>
verts;
1873 for (
int j = 0; j <
surfaces.size(); j++) {
1874 std::vector<std::pair<int, int>> inputTags;
1875 std::vector<std::pair<int, int>> outTags;
1876 inputTags.push_back(std::make_pair(2,
surfaces[j].second));
1878 gmsh::model::getBoundary(inputTags, outTags,
true,
true,
true);
1879 verts[j].resize(outTags.size());
1880 for (
int i = 0; i < outTags.size(); i++)
1881 verts[j][i] = std::make_pair(
surfaces[j].second, outTags[i].second);
1888 const std::vector<std::vector<std::pair<int, int>>> &vertsOneSide,
1889 const std::vector<std::vector<std::pair<int, int>>> &vertsOtherSide,
1890 const int &indexTranslate,
const double &amountTranslate) {
1892 std::vector<double> paramCoords;
1893 std::vector<std::vector<double>> pointsOneSide;
1894 std::vector<std::pair<int, int>> periodicSurfs;
1896 for (
int i = 0; i < vertsOneSide.size(); i++) {
1897 pointsOneSide.resize(vertsOneSide[i].size());
1899 for (
int s = 0; s < vertsOneSide[i].size(); s++) {
1900 gmsh::model::getValue(0, vertsOneSide[i][s].second, paramCoords,
1902 pointsOneSide[s][indexTranslate] =
1903 pointsOneSide[s][indexTranslate] + amountTranslate;
1906 for (
int j = 0; j < vertsOtherSide.size(); j++) {
1908 for (
int l = 0; l < vertsOtherSide[j].size(); l++) {
1909 std::vector<double> pointsOtherSide;
1910 gmsh::model::getValue(0, vertsOtherSide[j][l].second, paramCoords,
1913 for (
int g = 0; g < pointsOneSide.size(); g++) {
1914 double a = pointsOtherSide[0] - pointsOneSide[g][0];
1915 double b = pointsOtherSide[1] - pointsOneSide[g][1];
1916 double c = pointsOtherSide[2] - pointsOneSide[g][2];
1918 if (std::sqrt(a * a) < 1e-10 &&
1919 pointsOneSide.size() == vertsOtherSide[j].size())
1920 if (std::sqrt(b * b) < 1e-10 &&
1921 pointsOneSide.size() == vertsOtherSide[j].size())
1922 if (std::sqrt(c * c) < 1e-10 &&
1923 pointsOneSide.size() == vertsOtherSide[j].size())
1927 if (know == pointsOneSide.size())
1928 periodicSurfs.push_back(std::make_pair(vertsOneSide[i][0].first,
1929 vertsOtherSide[j][0].first));
1932 return periodicSurfs;
1939 std::cout <<
" - Writing periodic equation file" << std::endl;
1942 std::vector<std::pair<int, int>> allVolumes;
1943 gmsh::model::getEntities(allVolumes, 3);
1946 std::vector<std::pair<int, int>> volSurfLinksX;
1947 std::vector<std::pair<int, int>> volSurfLinksY;
1948 std::vector<std::pair<int, int>> volSurfLinksZ;
1952 std::map<int, int> masterLinksX;
1953 std::map<int, int> masterLinksY;
1954 std::map<int, int> masterLinksZ;
1957 for (
int i = 0; i < allVolumes.size(); i++) {
1958 std::vector<std::pair<int, int>> inputTags;
1959 std::vector<std::pair<int, int>> outTags;
1960 inputTags.push_back(std::make_pair(3, allVolumes[i].second));
1962 gmsh::model::getBoundary(inputTags, outTags,
true,
true,
false);
1964 for (
int j = 0; j <
slaveX.size(); j++)
1965 for (
int jj = 0; jj < outTags.size(); jj++)
1966 if (outTags[jj].first == 2 && outTags[jj].second ==
slaveX[j])
1967 volSurfLinksX.push_back(
1968 std::make_pair(allVolumes[i].second,
slaveX[j]));
1970 for (
int k = 0; k <
slaveY.size(); k++)
1971 for (
int kk = 0; kk < outTags.size(); kk++)
1972 if (outTags[kk].first == 2 && outTags[kk].second ==
slaveY[k])
1973 volSurfLinksY.push_back(
1974 std::make_pair(allVolumes[i].second,
slaveY[k]));
1976 for (
int l = 0; l <
slaveZ.size(); l++)
1977 for (
int ll = 0; ll < outTags.size(); ll++)
1978 if (outTags[ll].first == 2 && outTags[ll].second ==
slaveZ[l])
1979 volSurfLinksZ.push_back(
1980 std::make_pair(allVolumes[i].second,
slaveZ[l]));
1982 for (
int j = 0; j <
MasterX.size(); j++)
1983 for (
int jj = 0; jj < outTags.size(); jj++)
1984 if (outTags[jj].first == 2 && outTags[jj].second ==
MasterX[j])
1985 masterLinksX.insert(std::make_pair(
MasterX[j], allVolumes[i].second));
1987 for (
int k = 0; k <
MasterY.size(); k++)
1988 for (
int kk = 0; kk < outTags.size(); kk++)
1989 if (outTags[kk].first == 2 && outTags[kk].second ==
MasterY[k])
1990 masterLinksY.insert(std::make_pair(
MasterY[k], allVolumes[i].second));
1992 for (
int l = 0; l <
MasterZ.size(); l++)
1993 for (
int ll = 0; ll < outTags.size(); ll++)
1994 if (outTags[ll].first == 2 && outTags[ll].second ==
MasterZ[l])
1995 masterLinksZ.insert(std::make_pair(
MasterZ[l], allVolumes[i].second));
2002 std::vector<int> doNotRepeat;
2003 for (
int i = 0; i <
nptsMsh; i++) doNotRepeat.push_back(0);
2005 std::ofstream periodicEquation;
2006 periodicEquation.open(
"periodic.equ");
2007 periodicEquation <<
"**set definitions" << std::endl;
2008 periodicEquation <<
"*nset, nset=n0" << std::endl;
2009 periodicEquation <<
eqRefNodes[0] << std::endl;
2010 periodicEquation <<
"*nset, nset=nx" << std::endl;
2011 periodicEquation <<
eqRefNodes[1] << std::endl;
2012 periodicEquation <<
"*nset, nset=ny" << std::endl;
2013 periodicEquation <<
eqRefNodes[2] << std::endl;
2014 periodicEquation <<
"*nset, nset=nz" << std::endl;
2015 periodicEquation <<
eqRefNodes[3] << std::endl;
2016 periodicEquation <<
"*equation" << std::endl;
2022 for (
int srf = 0; srf < volSurfLinksX.size(); srf++) {
2024 std::vector<std::size_t> slaveNodes;
2025 std::vector<std::size_t> masterNodes;
2026 std::vector<double> affineTransformData;
2027 gmsh::model::mesh::getPeriodicNodes(2, volSurfLinksX[srf].second,
2028 masterSurfTag, slaveNodes, masterNodes,
2029 affineTransformData);
2040 if (srf == forSurfTestX && masterNodes.size() != 0) {
2041 int indReturn =
randomNodeX * masterNodes.size() / 100;
2042 std::vector<double> Mcoords;
2043 std::vector<double> Scoords;
2044 std::vector<double> paramCoords;
2046 gmsh::model::mesh::getNode(masterNodes[indReturn], Mcoords, paramCoords);
2047 gmsh::model::mesh::getNode(slaveNodes[indReturn], Scoords, paramCoords);
2049 if ((std::sqrt(Mcoords[0] * Mcoords[0]) -
2050 std::sqrt(Scoords[0] * Scoords[0])) < 1e-05)
2051 if ((std::sqrt(Mcoords[1] * Mcoords[1]) -
2052 std::sqrt(Scoords[1] * Scoords[1])) < 1e-05)
2053 if ((std::sqrt(Mcoords[2] * Mcoords[2]) -
2054 std::sqrt(Scoords[2] * Scoords[2])) < 1e-05)
2061 std::vector<int> newMasterNodes;
2062 std::vector<int> newSlaveNodes;
2064 for (
int i = 0; i < masterNodes.size(); i++) {
2066 newMasterNodes.push_back(
ptsReplacer[masterNodes[i] - 1]);
2067 newSlaveNodes.push_back(
ptsReplacer[slaveNodes[i] - 1]);
2070 for (
int i = 0; i < newMasterNodes.size(); i++) {
2071 masterNodes.push_back(newMasterNodes[i]);
2072 slaveNodes.push_back(newSlaveNodes[i]);
2076 for (
int i = 0; i < masterNodes.size(); i++) {
2081 if (doNotRepeat[slaveNodes[i] - 1] == 1) {
2084 doNotRepeat[slaveNodes[i] - 1] = 1;
2085 periodicEquation <<
"3" << std::endl;
2086 periodicEquation << slaveNodes[i] <<
",1,-1," << masterNodes[i]
2087 <<
",1,1," <<
eqRefNodes[1] <<
",1,1" << std::endl;
2089 periodicEquation <<
"3" << std::endl;
2090 periodicEquation << slaveNodes[i] <<
",2,-1," << masterNodes[i]
2091 <<
",2,1," <<
eqRefNodes[1] <<
",2,1" << std::endl;
2093 periodicEquation <<
"3" << std::endl;
2094 periodicEquation << slaveNodes[i] <<
",3,-1," << masterNodes[i]
2095 <<
",3,1," <<
eqRefNodes[1] <<
",3,1" << std::endl;
2102 for (
int srf = 0; srf < volSurfLinksY.size(); srf++) {
2104 std::vector<std::size_t> slaveNodes;
2105 std::vector<std::size_t> masterNodes;
2106 std::vector<double> affineTransformData;
2107 gmsh::model::mesh::getPeriodicNodes(2, volSurfLinksY[srf].second,
2108 masterSurfTag, slaveNodes, masterNodes,
2109 affineTransformData);
2120 if (srf == forSurfTestY && masterNodes.size() != 0) {
2121 int indReturn =
randomNodeY * masterNodes.size() / 100;
2122 std::vector<double> Mcoords;
2123 std::vector<double> Scoords;
2124 std::vector<double> paramCoords;
2126 gmsh::model::mesh::getNode(masterNodes[indReturn], Mcoords, paramCoords);
2127 gmsh::model::mesh::getNode(slaveNodes[indReturn], Scoords, paramCoords);
2129 if ((std::sqrt(Mcoords[0] * Mcoords[0]) -
2130 std::sqrt(Scoords[0] * Scoords[0])) < 1e-05)
2131 if ((std::sqrt(Mcoords[1] * Mcoords[1]) -
2132 std::sqrt(Scoords[1] * Scoords[1])) < 1e-05)
2133 if ((std::sqrt(Mcoords[2] * Mcoords[2]) -
2134 std::sqrt(Scoords[2] * Scoords[2])) < 1e-05)
2141 std::vector<int> newMasterNodes;
2142 std::vector<int> newSlaveNodes;
2144 for (
int i = 0; i < masterNodes.size(); i++) {
2146 newMasterNodes.push_back(
ptsReplacer[masterNodes[i] - 1]);
2147 newSlaveNodes.push_back(
ptsReplacer[slaveNodes[i] - 1]);
2151 for (
int i = 0; i < newMasterNodes.size(); i++) {
2152 masterNodes.push_back(newMasterNodes[i]);
2153 slaveNodes.push_back(newSlaveNodes[i]);
2157 for (
int i = 0; i < masterNodes.size(); i++) {
2162 if (doNotRepeat[slaveNodes[i] - 1] == 1) {
2165 doNotRepeat[slaveNodes[i] - 1] = 1;
2166 periodicEquation <<
"3" << std::endl;
2167 periodicEquation << slaveNodes[i] <<
",1,-1," << masterNodes[i]
2168 <<
",1,1," <<
eqRefNodes[2] <<
",1,1" << std::endl;
2170 periodicEquation <<
"3" << std::endl;
2171 periodicEquation << slaveNodes[i] <<
",2,-1," << masterNodes[i]
2172 <<
",2,1," <<
eqRefNodes[2] <<
",2,1" << std::endl;
2174 periodicEquation <<
"3" << std::endl;
2175 periodicEquation << slaveNodes[i] <<
",3,-1," << masterNodes[i]
2176 <<
",3,1," <<
eqRefNodes[2] <<
",3,1" << std::endl;
2183 for (
int srf = 0; srf < volSurfLinksZ.size(); srf++) {
2185 std::vector<std::size_t> slaveNodes;
2186 std::vector<std::size_t> masterNodes;
2187 std::vector<double> affineTransformData;
2188 gmsh::model::mesh::getPeriodicNodes(2, volSurfLinksZ[srf].second,
2189 masterSurfTag, slaveNodes, masterNodes,
2190 affineTransformData);
2201 if (srf == forSurfTestZ && masterNodes.size() != 0) {
2202 int indReturn =
randomNodeZ * masterNodes.size() / 100;
2203 std::vector<double> Mcoords;
2204 std::vector<double> Scoords;
2205 std::vector<double> paramCoords;
2207 gmsh::model::mesh::getNode(masterNodes[indReturn], Mcoords, paramCoords);
2208 gmsh::model::mesh::getNode(slaveNodes[indReturn], Scoords, paramCoords);
2210 if ((std::sqrt(Mcoords[0] * Mcoords[0]) -
2211 std::sqrt(Scoords[0] * Scoords[0])) < 1e-05)
2212 if ((std::sqrt(Mcoords[1] * Mcoords[1]) -
2213 std::sqrt(Scoords[1] * Scoords[1])) < 1e-05)
2214 if ((std::sqrt(Mcoords[2] * Mcoords[2]) -
2215 std::sqrt(Scoords[2] * Scoords[2])) < 1e-05)
2222 std::vector<int> newMasterNodes;
2223 std::vector<int> newSlaveNodes;
2225 for (
int i = 0; i < masterNodes.size(); i++) {
2227 newMasterNodes.push_back(
ptsReplacer[masterNodes[i] - 1]);
2228 newSlaveNodes.push_back(
ptsReplacer[slaveNodes[i] - 1]);
2232 for (
int i = 0; i < newMasterNodes.size(); i++) {
2233 masterNodes.push_back(newMasterNodes[i]);
2234 slaveNodes.push_back(newSlaveNodes[i]);
2238 for (
int i = 0; i < masterNodes.size(); i++) {
2243 if (doNotRepeat[slaveNodes[i] - 1] == 1) {
2245 doNotRepeat[slaveNodes[i] - 1] = 1;
2246 periodicEquation <<
"3" << std::endl;
2247 periodicEquation << slaveNodes[i] <<
",1,-1," << masterNodes[i]
2248 <<
",1,1," <<
eqRefNodes[3] <<
",1,1" << std::endl;
2250 periodicEquation <<
"3" << std::endl;
2251 periodicEquation << slaveNodes[i] <<
",2,-1," << masterNodes[i]
2252 <<
",2,1," <<
eqRefNodes[3] <<
",2,1" << std::endl;
2254 periodicEquation <<
"3" << std::endl;
2255 periodicEquation << slaveNodes[i] <<
",3,-1," << masterNodes[i]
2256 <<
",3,1," <<
eqRefNodes[3] <<
",3,1" << std::endl;
2261 periodicEquation.close();
2280 std::vector<std::pair<int, int>> tagsIndividual;
2281 tagsIndividual.push_back(std::make_pair(3, vol));
2288 std::vector<std::pair<int, int>> tagsSurfs;
2289 gmsh::model::getEntities(tagsSurfs, 2);
2291 for (
int i = 0; i < tagsSurfs.size(); i++) {
2292 gmsh::model::mesh::setSmoothing(tagsSurfs[i].first, tagsSurfs[i].second,
2295 gmsh::model::occ::synchronize();
2299 const std::string &outname) {
2311 std::vector<std::size_t> tmpNodeTags;
2314 for (
int j = 0; j < tmpNodeTags.size(); j++)
2322 std::vector<std::size_t> tmpNodeTags;
2326 for (
int j = 0; j < tmpNodeTags.size(); j++)
2332 std::vector<double> noUse;
2337 std::vector<std::size_t> tmpNodes;
2338 gmsh::model::mesh::getNodes(tmpNodes,
geomsCoords, noUse, 3,
2341 for (
int j = 0; j < tmpNodes.size(); j++)
2347 std::vector<int> elementTypes;
2348 std::vector<std::vector<std::size_t>> elementTags;
2349 std::vector<std::vector<std::size_t>> nodeTags;
2351 gmsh::model::mesh::getElements(elementTypes, elementTags, nodeTags, 3,
2354 for (
int i = 0; i < elementTags.size(); i++)
2355 for (
int j = 0; j < elementTags[i].size(); j++)
2363 size_t lastindex = filename.find_last_of(
".");
2364 std::string rawname = filename.substr(0, lastindex);
2365 rawname = rawname +
"_oldMSH.msh";
2369 size_t lastindex2 = outname.find_last_of(
".");
2370 std::string rawname2 = outname.substr(0, lastindex2);
2371 rawname2 = rawname2 +
"_withCohesive.vtu";
2374 vtkSmartPointer<vtkDataSet> dataSetSurr;
2377 int numCells = dataSetSurr->GetNumberOfCells();
2378 int numPoints = dataSetSurr->GetNumberOfPoints();
2381 for (
int i = 0; i < numPoints; i++)
ptsCohesiveGrp.push_back(-1);
2384 int countParts = 100;
2386 std::vector<std::size_t> storeNodes;
2388 std::vector<std::size_t> getNodeTags;
2389 std::vector<double> notUseful;
2390 std::vector<double> notUseful2;
2391 gmsh::model::mesh::getNodes(getNodeTags, notUseful, notUseful2, 3,
2394 for (
int k = 0; k < getNodeTags.size(); k++)
2395 storeNodes.push_back(getNodeTags[k]);
2398 for (
int j = 0; j < storeNodes.size(); j++) {
2417 std::vector<int> newPtIds;
2420 vtkSmartPointer<vtkUnstructuredGrid> dataSetCohesive =
2423 vtkSmartPointer<vtkUnstructuredGrid> dataSetViz =
2429 std::vector<int> ptsInterfaceID;
2432 std::vector<int> traceBackToSurr;
2434 std::vector<int> identifyInterfaceNodes;
2436 for (
int i = 0; i < numPoints; i++) {
2437 std::vector<double> getPt = std::vector<double>(3);
2438 dataSetSurr->GetPoint(i, &getPt[0]);
2439 pointsViz->InsertNextPoint(getPt[0], getPt[1], getPt[2]);
2440 identifyInterfaceNodes.push_back(0);
2442 ptsInterfaceID.push_back(0);
2443 traceBackToSurr.push_back(i);
2449 start = std::clock();
2459 std::vector<double> getPt = std::vector<double>(3);
2461 int newP = pointsViz->InsertNextPoint(getPt[0], getPt[1], getPt[2]);
2462 newPtIds.push_back(newP);
2464 traceBackToSurr.push_back(geomsNodeTags[i] - 1);
2469 duration = (std::clock() - start) / (
double)CLOCKS_PER_SEC;
2470 std::cout <<
"Process Finished!" << std::endl;
2471 std::cout <<
"Total " <<
interfaceNodes.size() <<
" Nodes duplicated in " 2472 << duration <<
" seconds!" << std::endl;
2474 dataSetCohesive->SetPoints(pointsViz);
2475 dataSetViz->SetPoints(pointsViz);
2478 ptsInterfaceID.push_back(1);
2484 std::vector<int> cellIdentification;
2487 for (
int i = 0; i < numCells; i++) cellIdentification.push_back(0);
2491 std::vector<int> pickCells;
2495 for (
int j = 0; j < cells->GetNumberOfIds(); j++) {
2497 cellIdentification[cells->GetId(j)] = 1;
2498 pickCells.push_back(cells->GetId(j));
2502 sort(pickCells.begin(), pickCells.end());
2503 pickCells.erase(unique(pickCells.begin(), pickCells.end()), pickCells.end());
2509 for (
int i = 0; i < numCells; i++) {
2512 if (cellIdentification[i] == 1) {
2513 cell = dataSetSurr->GetCell(i);
2514 vtkIdList *pts = cell->GetPointIds();
2515 std::vector<int> ptForCells;
2516 ptForCells.resize(4);
2517 for (
int j = 0; j < 4; j++) ptForCells[j] =
ptsReplacer[pts->GetId(j)];
2520 cell = dataSetSurr->GetCell(i);
2521 vtkIdList *pts = cell->GetPointIds();
2522 std::vector<int> ptForCells;
2523 ptForCells.resize(4);
2524 for (
int j = 0; j < 4; j++) ptForCells[j] = pts->GetId(j);
2531 std::vector<int> seqNodeMap;
2532 std::vector<int> cellFinal;
2533 std::vector<int> cellsNotPicked;
2536 for (
int i = 0; i < pickCells.size(); i++) {
2538 cell = dataSetCohesive->GetCell(pickCells[i]);
2539 vtkIdList *pts = cell->GetPointIds();
2540 vtkCell3D *cell3d =
static_cast<vtkCell3D *
>(cell);
2544 for (
int j = 0; j < 4; j++) {
2545 std::vector<int> tmpSeqStore;
2546 int *ptFaces =
nullptr;
2547 cell3d->GetFacePoints(j, ptFaces);
2548 for (
int k = 0; k < 3; k++)
2549 if (ptsInterfaceID[pts->GetId(ptFaces[k])] == 1)
2550 tmpSeqStore.push_back(pts->GetId(ptFaces[k]));
2552 if (tmpSeqStore.size() == 3)
2553 for (
int n = 0; n < 3; n++) seqNodeMap.push_back(tmpSeqStore[n]);
2558 std::vector<double> groupId;
2559 for (
int i = 0; i < grpIds.size(); i++) groupId.push_back(grpIds[i]);
2563 for (
int i = 0; i < (seqNodeMap.size() / 3); i++) {
2564 std::vector<int> ptForCells;
2565 ptForCells.resize(6);
2566 for (
int j = 0; j < 3; j++) {
2567 ptForCells[j] = seqNodeMap[j + add];
2568 ptForCells[j + 3] = traceBackToSurr[seqNodeMap[j + add]];
2572 std::vector<double> getPt1 = std::vector<double>(3);
2573 std::vector<double> getPt2 = std::vector<double>(3);
2574 std::vector<double> getPt3 = std::vector<double>(3);
2575 dataSetCohesive->GetPoint(ptForCells[0], &getPt1[0]);
2576 dataSetCohesive->GetPoint(ptForCells[1], &getPt2[0]);
2577 dataSetCohesive->GetPoint(ptForCells[2], &getPt3[0]);
2620 if (groupId.size() != dataSetCohesive->GetNumberOfCells()) {
2621 std::cerr <<
"Exception at group id vector size" << std::endl;
2636 const int cellType, std::vector<int> &vrtIds) {
2638 vtkCellIds->SetNumberOfIds(vrtIds.size());
2639 for (
auto pit = vrtIds.begin(); pit != vrtIds.end(); pit++)
2640 vtkCellIds->SetId(pit - vrtIds.begin(), *pit);
2641 dataSet->InsertNextCell(cellType, vtkCellIds);
2660 Xdim = domainBounds[3];
2661 Ydim = domainBounds[4];
2662 Zdim = domainBounds[5];
2676 std::size_t cellTag;
2678 std::vector<std::size_t> nodeIds;
2682 gmsh::model::mesh::getElementByCoordinates(
boxPt[0],
boxPt[1],
boxPt[2],
2683 cellTag, cellType, nodeIds, u, v,
2686 for (
int i = 0; i < nodeIds.size(); i++) {
2687 std::vector<double> coords;
2688 std::vector<double> paramCoords;
2690 gmsh::model::mesh::getNode(nodeIds[i], coords, paramCoords);
2692 if (coords[0] ==
boxPt[0])
2693 if (coords[1] ==
boxPt[1])
2699 gmsh::model::mesh::getElementByCoordinates(
boxPt[0] +
Xdim,
boxPt[1],
2700 boxPt[2], cellTag, cellType,
2701 nodeIds, u, v, w, elemDim,
true);
2703 for (
int i = 0; i < nodeIds.size(); i++) {
2704 std::vector<double> coords;
2705 std::vector<double> paramCoords;
2707 gmsh::model::mesh::getNode(nodeIds[i], coords, paramCoords);
2710 if (coords[1] ==
boxPt[1]) {
2711 if (coords[2] ==
boxPt[2]) {
2720 gmsh::model::mesh::getElementByCoordinates(
boxPt[0],
boxPt[1] +
Ydim,
2721 boxPt[2], cellTag, cellType,
2722 nodeIds, u, v, w, elemDim,
true);
2723 for (
int i = 0; i < nodeIds.size(); i++) {
2724 std::vector<double> coords;
2725 std::vector<double> paramCoords;
2727 gmsh::model::mesh::getNode(nodeIds[i], coords, paramCoords);
2729 if (coords[0] ==
boxPt[0]) {
2731 if (coords[2] ==
boxPt[2]) {
2740 gmsh::model::mesh::getElementByCoordinates(
boxPt[1],
boxPt[2],
2742 nodeIds, u, v, w, elemDim,
true);
2743 for (
int i = 0; i < nodeIds.size(); i++) {
2744 std::vector<double> coords;
2745 std::vector<double> paramCoords;
2747 gmsh::model::mesh::getNode(nodeIds[i], coords, paramCoords);
2749 if (coords[0] ==
boxPt[0]) {
2750 if (coords[1] ==
boxPt[1]) {
2762 const std::vector<double> &getPt2,
2763 const std::vector<double> &getPt3) {
2766 if ((getPt1[0] ==
boxPt[0]) && (getPt2[0] ==
boxPt[0]) &&
2767 (getPt3[0] ==
boxPt[0]))
2774 else if ((getPt1[1] ==
boxPt[1]) && (getPt2[1] ==
boxPt[1]) &&
2775 (getPt3[1] ==
boxPt[1]))
2782 else if ((getPt1[2] ==
boxPt[2]) && (getPt2[2] ==
boxPt[2]) &&
2783 (getPt3[2] ==
boxPt[2]))
2794 size_t lastindex = modifyFile.find_last_of(
".");
2795 std::string rawname = modifyFile.substr(0, lastindex);
2796 std::string fname = rawname +
".inp";
2797 std::vector<std::string> fileLines;
2798 std::ifstream meshFile(fname);
2799 if (meshFile.is_open()) {
2801 std::string linesOut;
2802 while (std::getline(meshFile, linesOut)) fileLines.push_back(linesOut);
2806 for (
int i = 0; i < fileLines.size(); i++) {
2807 if (fileLines[i].find(
"*ELEMENT, type=CPS3, ELSET=") == 0) {
2813 for (
int i = 0; i < fileLines.size(); i++) {
2815 if (fileLines[i].find(
"*ELEMENT, type=C3D4, ELSET=") == 0) {
2826 if (start == 0 || end == 0) {
2831 fileLines.erase(fileLines.begin() + start, fileLines.begin() + end);
2834 std::ofstream outFile;
2835 outFile.open(
"NewModifiedMesh.inp");
2836 for (
int i = 0; i < fileLines.size(); i++)
2837 outFile << fileLines[i] << std::endl;
2840 if (std::remove(fname.c_str()) == 0) {
2841 if (std::rename(
"NewModifiedMesh.inp", fname.c_str()) != 0) {
2842 std::cerr <<
"Could not rename file NewModifiedMesh.inp to " << fname
2847 std::cerr <<
"Could not remove file " << fname << std::endl;
2851 std::cerr <<
"Cannot open/find " << fname <<
" file!" << std::endl;
void setSizePreservation()
Sets program for size preservation instead of volume fraction.
int randomNodeX
For testing.
std::vector< std::vector< double > > rotateParams
Vector of rotate coordinates for all packs.
void setElementOrder(const int &order)
Sets element order.
void geomToPeriodic3D()
This method writes 3D periodic mesh into .msh and vtu format.
void enableDefOuts()
Enables .stl, .vtu.
double shrinkScale
Shrink Scale.
std::vector< int > MasterZ
Master periodic surfaces in Z direction.
void rocPack2Surf()
rocPack2Surf method converts Rocpack output file into STL/VTK surface mesh and writes into current fo...
double filterBelow
Lower limit for filtering.
double Zdim
Z dimension of box geometry.
static meshBase * exportGmshToVtk(const std::string &fname)
construct vtkMesh from gmsh msh file (called in Create methods)
void setNodeLocations(const int &x, const int &y, const int &z)
For internal testing purpose.
void geomToSurf()
This method creates surface mesh for final geometry and writes into surface files (...
bool cstmDomain
Custom Domain Boolean.
std::vector< std::vector< std::vector< double > > > verts
Vector of crystal shape vertices.
void writePeriodicNodes()
This method allows mapping of nodes on periodic boundaries.
double Xdim
X dimension of box geometry.
std::vector< std::size_t > surrNodeTags
Stores node tags for surronding physical group.
void removeBoundaryVolumes()
Enables an option to remove volumes intersecting boundary.
std::string InFile
rocPack output file name
std::vector< int > slaveInterfaceId
Storage vector for identifying which slave nodes are interface nodes.
std::vector< int > eqRefNodes
Stores node ids n0,nx,ny,nz.
A brief description of meshBase.
void enablePhysicalGroupsPerShape()
Enables physical group per shape.
bool existsOnPeriodicBoundary(const std::vector< double > &getPt1, const std::vector< double > &getPt2, const std::vector< double > &getPt)
This method check if cohesive element face lies on any of the periodic boundaries.
double zUDF
Z coordinate for user-defined translate.
A struct to respresent quaternion.
void modifyInpMesh(const std::string &modifyFile)
Removes 2D elements from INP mesh file.
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
void makeEllipsoid(const int &n)
Creates Ellipsoid pack shapes.
int randomSurfTest
Random location for a surface.
bool defOutputs
Output control.
std::string OutFile
Output STL/VTK file name.
void scaleVols(const int &vol, const int &index)
Scales all volumes by shrinking percentage.
std::vector< int > slaveY
Surfaces linked to master periodic surface in Y direction.
bool removeBoundaryPacks
Boolean to opt for removing packs on boundaries.
std::vector< std::string > Tokenize(const std::string &lineIn, const char &delim)
std::vector< int > ellipsoidPhysicalGroup
Arrays for group per shape.
static meshBase * Create(const std::string &fname)
Construct vtkMesh from filename.
void setRandomSurface(const int &surf)
For internal testing purpose.
void setCellDataArray(const std::string &name, const std::vector< std::vector< double >> &data) override
register data to dataSet's cell data
bool enableScaling
Enables Shrinking.
bool just2Physgrps
Enable Two Physical Groups in Final Mesh.
double filterAbove
Upper limit for filtering.
std::vector< int > slaveX
Surfaces linked to master periodic surface in X direction.
std::shared_ptr< char > strToChar(const std::string &strng)
static std::shared_ptr< rocPackShape > getShape(const std::string &shapeName)
Creates shape object for requsted shape.
void enableTwoPhysGrps()
Enables two physical groups in final mesh.
int meshingAlgorithm
Meshing Algorithm.
std::vector< double > ellipsoidRad
Vector of Ellipsoid radii.
std::vector< std::vector< double > > translateParams
Vector of translate coordinates for all packs.
std::vector< double > scaleOfPack
Vector of scales for all packs.
std::vector< int > spherePhysicalGroup
Arrays for group per shape.
void geomToSTL(const std::string &writeFile)
This method writes periodic pack geometries into STL format.
std::vector< std::vector< std::vector< int > > > faces
Vector of crystal shape faces.
bool enableSizePreserve
Boolean for size preservation.
std::vector< std::size_t > geomsNodeTags
Stores node tags for geometries physical group.
std::vector< std::pair< int, int > > getPeriodicSurfs(const std::vector< std::vector< std::pair< int, int >>> &vertsOneSide, const std::vector< std::vector< std::pair< int, int >>> &vertsOtherSide, const int &indexTranslate, const double &amountTranslate)
This method find which surfaces are periodic on opposite sides.
std::vector< double > cylParams
Vector of cylinder parameters.
int nptsMsh
Total numer of points in mesh.
std::vector< int > icosidodecahedronPhysicalGroup
Arrays for group per shape.
std::vector< int > petnPhysicalGroup
Arrays for group per shape.
vtkSmartPointer< vtkDataSet > getDataSet() const
get this meshes' dataSet
std::vector< std::string > crystalNames
Vector for storing crystal names.
void rocParser()
This method parses Rocpack output file and collects data for creation of pack geometries.
std::vector< double > boxPt
Vector of box starting coordinates.
int smoothingIter
some smoothing parameter
bool internalCohesiveBool
Boolean to enable cohesive elements.
void setPeriodicGeometry()
Enables an option to enforce periodicity on generated geometry.
std::vector< int > MasterY
Master periodic surfaces in Y direction.
void setMeshingAlgorithm(const int &mshAlg)
Sets meshing algorithm of user's choice.
void performSmoothing()
Performs laplacian smoothing on all packs if requested.
bool enableSmoothing
Enables smoothing.
nemId_t getNumberOfPoints() const
return the number of points
void toLower(std::string &str)
void makeSphere(const int &n)
Creates sphere pack shapes.
void initialize()
Initializes GMSH for workflow.
void createVtkCell(vtkSmartPointer< vtkUnstructuredGrid > dataSet, const int cellType, std::vector< int > &vrtIds)
creates VTK cell
virtual void write() const
write the mesh to file named after the private var 'filename'.
void assignPeriodicEqNodes()
Assigns nodes n0, nx, ny, nz for periodic equation file.
void rocPack2Periodic3D()
rocPack2Periodic3D method converts Rocpack output file into 3D periodic mesh.
void setPeriodicMesh()
Enables an option to enforce periodicity on generated mesh.
int randomNodeY
For testing.
std::vector< std::size_t > interfaceNodes
Vector for stroing nodes at conformal interface.
void geomToVTK(const std::string &writeFile)
This method writes periodic pack geometries into VTK format.
int randomNodeZ
For testing.
std::vector< int > slaveZ
Surfaces linked to master periodic surface in Z direction.
void makeCylinder(const int &n)
Creates cylinder pack shapes.
bool enablePhysGrp
Enable Physical Grouping in Final Mesh.
std::vector< double > surrCoords
Stores node coordinates for surronding physical group.
bool getTestResult()
This method is for internal testing purpose only.
bool matchingCoordsY
Y Nodes for testing.
std::vector< std::string > getShapeData(const int &iter, const std::string &a, const std::vector< std::string > &L)
Reads the current line and returns the translate, rotate, and scale data for the pack shape...
void geomToMsh(const std::string &writeFile)
This method writes periodic pack geometries into .MSH format.
void sanityCheckOn()
Sanity check for cohesive element method when there are no volumes in domain.
std::vector< int > geomElementIds
Store cells in surrounding for cohesive elements without physical groups.
void enablePhysicalGrps()
Enables physical grouping in final mesh.
void enableSurfacePatches()
Enables 6 surface patches for all sides of box.
void assignRefinement(const int &refineLvl)
Assigns refinement levels to mesh.
void createCohesiveElements(const std::string &filename, const std::string &outname)
This method creates cohesive elements using existing vtu file.
std::string findWord(const std::string &word)
Finds particular word in file stream.
rocQuaternion toQuaternion(const std::vector< double > &r)
Generates a Quaternion using Euler 3D rotation parameters.
void smoothSurfaces(const int smoothingParam)
Performs surface smoothing over every volume in pack geometry.
std::map< std::string, std::vector< std::pair< vtkIdType, int > > > surfaces
Map from SURFACE name to (element id, side) (id and side both use .inp IDs)
std::map< int, int > storeShapeNames
Map for storing shape names against volume Sphere = 0 Ellipsoid = 1 Cylinder = 2 HMX = 3 PETN = 4 Ico...
std::vector< std::vector< std::pair< int, int > > > getAllPoints(std::vector< std::pair< int, int >> surfaces)
This method gets points that belongs to surfaces.
bool assignSidePatches
A boolean for user to enable assignement of surface patches.
std::vector< int > multiGrpIndices
Group indices for multi groups (useful in cohesive elements)
std::vector< int > hmxPhysicalGroup
Arrays for group per shape.
bool ellipsoidPresent
Ellipsoid packs cannot be made periodic as of now.
void setMeshSize(const double size)
Set mesh size for periodic mesh.
void makePeriodic(const bool rmbPacks)
Enforced periodicity on geometry.
std::vector< int > ptsReplacer
Storage vector for linking interface and duplicate nodes Replaces new duplicated nodes at place of ol...
std::vector< std::string > uniqueNames
Vector for storing shapes.
void rocToGeom()
This method obtains parsed data from Rocpack output and creates periodic pack geometries.
double yUDF
Y coordinate for user-defined translate.
void tagBoundaryPacks()
This method removes the pack shapes intersecting boundary.
void translateAll(const double &X, const double &Y, const double &Z)
Translates the whole geometry along user-defined parameters.
int surroundingGrp
Tag number.
double Ydim
Y dimension of box geometry.
bool physGrpPerShape
Boolean for physical group per shape.
void enableCohesiveElements()
Enables cohesive elements.
virtual void getCellDataArray(const std::string &name, std::vector< double > &data)
<>
void setCustomDomain(const std::vector< double > &domainBounds)
Sets custom domain size defined by users.
bool matchingCoordsZ
Z Nodes for testing.
std::vector< std::string > nameOfPcks
Vector of pack shape names.
double xUDF
X coordinate for user-defined translate.
bool matchingCoordsX
X Nodes for testing.
void applyFilter(const double &upperThreshold, const double &lowerThreshold)
Assigns limiting filters for geometry sizes.
std::vector< std::vector< int > > storeMultiPhysGrps
Stores all physical groups in index sized by total volumes.
int refineIter
mesh refinement iterations
bool filterOn
Boolean for filter.
std::vector< double > rotateByQuaternion(const rocQuaternion &q, const std::vector< double > &v)
Rotates a 3D Vector by unit Quaternion.
std::vector< std::pair< int, int > > bndryPackTags
Stores volume index of packs interseting boundary.
void shrinkVolumes(const double percntg)
Shrinks the volumes by defined percentage.
std::vector< int > filteredGeoms
Vector for identification of removed geometries.
std::vector< std::string > shapeNames
Vector for storing base shape names.
std::vector< int > MasterX
Master periodic surfaces in X direction.
nemId_t getNumberOfCells() const
return the number of cells
std::vector< int > cylindersPhysicalGroup
Arrays for group per shape.
void normalizeVerts()
Normalizes shape vertices.
std::vector< int > linkMultiPhysGrps
Vector of all volumes for multi-physical groups.
std::vector< int > ptsCohesiveGrp
psudo-physical group vector for cohesive elements material assignment
bool enablePeriodicity
Boolean to opt for non-periodic geometry (as generated by rocPack)
double globalScaling
Global scale for all pack geometries.
void report() const override
generate a report of the mesh
void write() const override
write the mesh to file named after the private var 'filename'.
rocPack(const std::string &fname, const std::string &outName)
rocPack default constructor.
std::vector< double > geomsCoords
Stores node coordinates for geometries physical group.
void mapPeriodicSurfaces(const std::vector< std::pair< int, int >> &prevTags)
This method maps surfaces in X,Y, and Z direction which are periodic and then enforces that into gmsh...
void makeCrystalShape(const int &n, const int &index)
Creates a crystal shape based on Rocpack output file.
int elementOrder
Sets mesh element order.
bool periodic3D
Boolean for 3D periodic mesh generation.