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.
VtkToFoamConversionDriver.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/foamMesh.H"
32 
33 namespace NEM {
34 namespace DRV {
35 
37  : inputMeshFile(std::move(input)) {}
38 
40  : file_(std::move(file)) {}
41 
44 
46  const {
47  return file_;
48 }
49 
51  this->file_ = std::move(file);
52 }
53 
55  if (this->file_.inputMeshFile.find(".vt") != std::string::npos) {
56  std::cout << "Detected file in VTK format" << std::endl;
57  std::cout << "Converting to FOAM Mesh ...." << std::endl;
58  } else {
59  std::cerr << "Source mesh file is not in VTK format" << std::endl;
60  }
61 
62  std::ifstream meshStream(this->file_.inputMeshFile);
63  if (!meshStream.good()) {
64  std::cerr << "Error opening file " << this->file_.inputMeshFile
65  << std::endl;
66  exit(1);
67  }
68  // create meshBase object
69  std::shared_ptr<meshBase> myMesh =
71 
72  // create foamMesh object
73  FOAM::foamMesh *fm = new FOAM::foamMesh(myMesh);
74 
75  // Write polyMesh
76  // fm->report();
77  fm->write({});
78 }
79 
81  const {
82  static constexpr Opts opts{};
83  return opts;
84 }
85 
86 } // namespace DRV
87 } // namespace NEM
STL namespace.
foamMesh class contains methods for reading and writing mesh in OpenFOAM polyMesh format...
Definition: foamMesh.H:49
void execute() const override
Run the workflow represented by the driver.
static std::shared_ptr< meshBase > CreateShared(const std::string &fname)
Create shared ptr from fname.
Definition: meshBase.C:171
void write(const std::string &fname) const override
write the mesh to file named fname
Definition: foamMesh.C:473