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.
MeshManipulationFoam.H
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 *******************************************************************************/
29 #ifndef NEMOSYS_MESHMANIPULATIONFOAM_H_
30 #define NEMOSYS_MESHMANIPULATIONFOAM_H_
31 
32 #include "nemosys_export.h"
33 
34 // VTK
35 #include <vtkDoubleArray.h>
36 #include <vtkMeshQuality.h>
37 
38 // OpenFOAM
39 #include <argList.H>
40 #include <fileName.H>
41 #include <fvMesh.H>
42 
43 // Nemosys
45 #include "Mesh/geoMeshFactory.H"
46 #include "Mesh/geoMeshBase.H"
47 #include "Mesh/foamGeoMesh.H"
48 #include "Mesh/vtkGeoMesh.H"
49 
50 //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
51 
52 /** @brief MeshManipulation class contains several OpenFOAM utilities to perform
53  various mesh manipulation operations. These utilities reads Foam mesh
54  and outputs Foam mesh. Some of them are surface mesh manipulation
55  utilities.
56  Manipulation utilities include
57  - surfaceLambdaMuSmooth
58  - splitMeshRegions
59  - mergeMeshes
60  - createPatch
61  - foamToSurface
62  - surfaceSplitByTopology.
63 
64  Foam mesh reading and writing capabilities are built inside each
65 manipulation utility.
66 **/
67 
68 class NEMOSYS_EXPORT MeshManipulationFoam {
69  // --- constructors and destructors
70  public:
71  /**
72  @brief Standard MeshManipulationFoam Constructor
73  **/
74  MeshManipulationFoam(){}; // Standard Constructor
75 
76  /**
77  @brief Custom MeshManipulationFoam Constructor
78  @param params MeshManipulationFoamParams Object
79  **/
81  _mshMnipPrms = params;
82  } // Alternate Constructor
83 
84  /**
85  @brief Standard MeshManipulationFoam Destructor
86  **/
87  ~MeshManipulationFoam(); // Class Destructor
88 
89  // --- meshBase factory methods
90  public:
91  /** @brief surfLambdaMuSmooth performs laplacian smoothing over surface
92  and writes it into output surface file. This utility supports .ofs,
93  .obj, .inp, .stl, .tri, .off, .stlb, .nas, .bdf, .gts, .vtk, .ac
94  extensions for input and output surface files.
95  **/
96  void surfLambdaMuSmooth(); // SurfaceLambdaMuSmooth utility
97 
98  /** @brief splitMshRegions walks through mesh using cell-face-cell walk and
99  identifies different cellZones as different regions. Writes these
100  regions in separate Foam meshes.
101  @param
102  @return domain number skipped during splitting, Total disconnected regions
103  **/
104  std::pair<std::vector<int>, std::vector<std::string>> splitMshRegions();
105 
106  /** @brief mergeMesh method merges two fvMesh datasets into one fvMesh
107  including the patches and domain information
108  @param dirStat domain number to skip (output from splitMshRegions)
109  @param nDomains Number of meshes to merge
110  **/
111  void mergeMesh(int dirStat, int nDomains); // MergeMeshes utility
112 
113  /** @brief createPtch utility creates user-defined patches in Foam mesh. User
114  input is usually createPatchDict.
115  @param dirStat domain number to skip (output from splitMshRegions)
116  **/
117  void createPtch(int dirStat); // CreatePatch utility
118 
119  /** @brief foamToSurf utility reads Foam mesh, extracts its surface and
120  writes into an STL file.
121  **/
122  void foamToSurf(); // FoamToSurface utility
123 
124  /** @brief surfSpltByTopology utility takes a surface file as an input and
125  automatically divides disconnected regions into separate patches.
126  writes a surface file with separated patches as well as multiple
127  surface files for separate patches.
128  **/
129  int surfSpltByTopology(); // surfaceSplitByTopology utility
130 
131  /** @brief addCohesiveElements method supports addition of zero-sized
132  connectivity elements at conformal shared interface between two
133  meshes. This method can take two .vtk/.vtu files or Foam meshes as
134  input and outputs a single .vtk/.vtu file with original meshes plus cohesive
135  elements.
136  @param tol Tolerance for conformal duplicate nodes between two meshes.
137  @param outName Output mesh name with extension (i.e "output.vtu")
138  **/
139  // Adds connectivity info at duplicate nodes.
140  void addCohesiveElements(double tol, const std::string &outName);
141 
142  /** @brief This method adds connectivity elements with finite thickness
143  at shared interface between two conformal meshes
144  @param tol Tolerance for conformal duplicate nodes between two meshes.
145  @param outName Output mesh name with extension (i.e "output.vtu")
146  @param thickness Desired thickness for new cohesive elements.
147  **/
148  void addArtificialThicknessElements(double &tol, const std::string &outName,
149  double &thickness);
150 
151  /** @brief periodicMeshMapper method generates map of nodes on periodic mesh
152  interfaces at boundaries for FEM analysis.
153  @param patch1 First boundary for mapping.
154  @param patch2 Second boundary for mapping.
155  **/
156  void periodicMeshMapper(std::string &patch1, std::string &patch2);
157 
158  // --- private methods
159  private:
160  /** @brief createPatchDict utility creates a dictionary needed for createPatch
161  method.
162  @param dirStat domain number to skip (output from splitMshRegions)
163  @param write Write boolean
164  **/
165  void createPatchDict(const int &dirStat, const bool &write);
166 
167  // Pointer for parameters
168  private:
169  /** @brief MeshManipulationFoam object
170  **/
172  std::unique_ptr<Foam::dictionary> cpDict_;
173 };
174 
175 #endif // NEMOSYS_MESHMANIPULATIONFOAM_H_
MeshManipulationFoam(MeshManipulationFoamParams *params)
Custom MeshManipulationFoam Constructor.
std::unique_ptr< Foam::dictionary > cpDict_
MeshManipulationFoamParams defines basic parameters needed for utilities in MeshManipulationFoam clas...
MeshManipulationFoamParams * _mshMnipPrms
MeshManipulationFoam object.
MeshManipulationFoam()
Standard MeshManipulationFoam Constructor.
MeshManipulation class contains several OpenFOAM utilities to perform various mesh manipulation opera...