NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
VtkToPatranConversionDriver.C
Go to the documentation of this file.
1 /*******************************************************************************
2 * Promesh *
3 * Copyright (C) 2022, IllinoisRocstar LLC. All rights reserved. *
4 * *
5 * Promesh is the property of IllinoisRocstar LLC. *
6 * *
7 * IllinoisRocstar LLC *
8 * Champaign, IL *
9 * www.illinoisrocstar.com *
10 * promesh@illinoisrocstar.com *
11 *******************************************************************************/
12 /*******************************************************************************
13 * This file is part of Promesh *
14 * *
15 * This version of Promesh is free software: you can redistribute it and/or *
16 * modify it under the terms of the GNU Lesser General Public License as *
17 * published by the Free Software Foundation, either version 3 of the License, *
18 * or (at your option) any later version. *
19 * *
20 * Promesh is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more *
23 * details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
27 * *
28 *******************************************************************************/
30 
31 #include "Mesh/patran.H"
32 
33 namespace NEM {
34 namespace DRV {
35 
37  : patchNum(patchNum) {}
38 
40  : BoundaryCond(patchNum), rocFracFSIType(rocFracFSIType) {}
41 
42 jsoncons::string_view VtkToPatranConversionDriver::FaceBC::getBCType() const {
43  return bcType;
44 }
45 
47  int rocfracControlType,
48  bool structural, bool meshMotion,
49  bool thermal)
50  : BoundaryCond(patchNum),
51  rocfracControlType(rocfracControlType),
52  structural(structural),
53  meshMotion(meshMotion),
54  thermal(thermal) {}
55 
56 jsoncons::string_view VtkToPatranConversionDriver::NodeBC::getBCType() const {
57  return bcType;
58 }
59 
61  std::vector<std::shared_ptr<BoundaryCond>> bcInfo,
62  std::vector<int> nodePatchPreference)
63  : bcInfo(std::move(bcInfo)),
64  nodePatchPreference(std::move(nodePatchPreference)) {}
65 
67  : files_(std::move(files)), opts_(std::move(opts)) {}
68 
70  : VtkToPatranConversionDriver({{}, {}}, {{}, {}}) {}
71 
74  return files_;
75 }
76 
78  this->files_ = std::move(files);
79 }
80 
82  const {
83  return opts_;
84 }
85 
87  this->opts_ = std::move(opts);
88 }
89 
91  if (this->files_.inputMeshFile.find(".vt") != std::string::npos) {
92  std::cout << "Detected file in VTK format" << std::endl;
93  std::cout << "Converting to PATRAN ...." << std::endl;
94  } else {
95  std::cerr << "Source mesh file is not in VTK format" << std::endl;
96  }
97 
98  std::ifstream meshStream(this->files_.inputMeshFile);
99  if (!meshStream.good()) {
100  std::cerr << "Error opening file " << this->files_.inputMeshFile
101  << std::endl;
102  exit(1);
103  }
104 
105  // looping through blocks
106  std::cout << "Number of Boundary Conditions read: "
107  << this->opts_.bcInfo.size() << std::endl;
108 
109  // PATRAN specific BC information
110  // Each map below maps the indicated information from the "Patch Number"
111  // specified in the file
112 
113  std::map<int, int> faceTypeMap; // Rocfrac FSI Type;
114  // 0 = no FSI, 1 = FSI w/ burn, 2 = FSI w/o burn, etc.
115  // see Rocfrac manual for details
116  std::map<int, int>
117  nodeTypeMap; // patch numbers as specified in RocfracControl.txt
118  std::map<int, bool> nodeStructuralMap; // boolean indicating structural BC
119  std::map<int, bool> nodeMeshMotionMap; // boolean indicating mesh motion BC
120  std::map<int, bool> nodeThermalMap; // boolean indicating heat transfer BC
121 
122  for (const auto &bcInfo : this->opts_.bcInfo) {
123  int patchNum = bcInfo->patchNum;
124  FaceBC *faceBC;
125  NodeBC *nodeBC;
126  if ((faceBC = dynamic_cast<FaceBC *>(bcInfo.get()))) {
127  faceTypeMap[patchNum] = faceBC->rocFracFSIType;
128  } else if ((nodeBC = dynamic_cast<NodeBC *>(bcInfo.get()))) {
129  nodeTypeMap[patchNum] = nodeBC->rocfracControlType;
130  nodeStructuralMap[patchNum] = nodeBC->structural;
131  nodeMeshMotionMap[patchNum] = nodeBC->meshMotion;
132  nodeThermalMap[patchNum] = nodeBC->thermal;
133  }
134  }
135 
136  // create meshBase object
137  std::shared_ptr<meshBase> myMesh =
139 
140  // create PATRAN object from meshBase
141  PATRAN::patran(myMesh, this->files_.inputMeshFile,
142  this->files_.outputMeshFile, faceTypeMap, nodeTypeMap,
143  nodeStructuralMap, nodeMeshMotionMap, nodeThermalMap,
144  this->opts_.nodePatchPreference);
145  // pat->write();
146 }
147 
148 } // namespace DRV
149 } // namespace NEM
int patchNum
patch numbers as specified in RocfracControl.txt
void execute() const override
Run the workflow represented by the driver.
bool thermal
boolean indicating heat transfer BC
jsoncons::string_view getBCType() const override
STL namespace.
bool meshMotion
boolean indicating mesh motion BC
jsoncons::string_view getBCType() const override
int rocFracFSIType
Rocfrac FSI Type; 0 = no FSI, 1 = FSI w/ burn, 2 = FSI w/o burn, etc.
std::string inputMeshFile
Definition: NemDriver.H:90
static std::shared_ptr< meshBase > CreateShared(const std::string &fname)
Create shared ptr from fname.
Definition: meshBase.C:171
std::vector< std::shared_ptr< BoundaryCond > > bcInfo
bool structural
boolean indicating structural BC