cellDecomposer.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2024 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::functionObjects::cellDecomposer
28 
29 Group
30  grpFieldFunctionObjects
31 
32 Description
33  Maps input fields from local mesh to a secondary mesh at runtime.
34 
35  The secondary mesh gets created on-the-fly by decomposing the current mesh.
36 
37 
38  Operands:
39  \table
40  Operand | Type | Location
41  input | {vol,surface}<Type>Field <!--
42  --> | $FOAM_CASE/<time>/<inpField>
43  output file | - | -
44  output field | {vol,surface}<Type>Field <!--
45  --> | $FOAM_CASE/<time>/<outField>
46  \endtable
47 
48  where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
49 
50 Usage
51  Minimal example by using \c system/controlDict.functions:
52  \verbatim
53  cellDecomposer1
54  {
55  // Mandatory entries (unmodifiable)
56  type cellDecomposer;
57  libs (fieldFunctionObjects);
58 
59  // Mandatory (inherited) entries (runtime modifiable)
60  fields (<field1> <field2> ... <fieldN>);
61  mapRegion myTetMesh;
62  ...
63  // Mandatory entries
64  // Decompose type:
65  decomposeType polyhedral;
66  // Cell set to decompose
67  selectionMode all;
68  }
69  \endverbatim
70 
71  where the entries mean:
72  \table
73  Property | Description | Type | Req'd | Dflt
74  type | Type name: cellDecomposer | word | yes | -
75  libs | Library name: fieldFunctionObjects | word | yes | -
76  fields | Names of operand fields | wordList | yes | -
77  mapRegion | Name of region to map to | word | yes | -
78  decomposeType | How to decompose cells | word | yes | -
79  selectionMode | How to select cells (see fvOption)| word | yes | -
80  \endtable
81 
82  decomposeType:
83  - faceCentre : decompose cells into tets using face centre and cell centre.
84  (hex becomes 6*4 tets)
85  - faceDiagonal : decompose cells into tets using face diagonal, similar
86  to implicit decomposition inside lagrangian tracking.
87  (hex becomes 6*2 tets)
88  - pyramid : keep faces intact but create (polygonal-base) pyramids using
89  cell centre (hex becomes 6 pyramids)
90  - faceDiagonalQuads : like faceDiagonal but split faces into quads and
91  triangles instead of just triangles
92  - polyhedral : like faceDiagonalQuads but only decompose non-hex/prism/tet
93  cells in selected set. Used to convert polyhedral mesh into
94  'simple' mesh.
95 
96  The inherited entries are elaborated in:
97  - \link functionObject.H \endlink
98 
99 See also
100  - Foam::functionObjects::mapFields
101 
102 SourceFiles
103  cellDecomposer.C
104 
105 \*---------------------------------------------------------------------------*/
106 
107 #ifndef functionObjects_cellDecomposer_H
108 #define functionObjects_cellDecomposer_H
109 
110 #include "fvMeshFunctionObject.H"
111 #include "volFieldsFwd.H"
112 
113 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114 
115 namespace Foam
116 {
117 
118 class tetDecomposer;
119 class mapPolyMesh;
120 
121 namespace functionObjects
122 {
123 
124 /*---------------------------------------------------------------------------*\
125  Class cellDecomposer Declaration
126 \*---------------------------------------------------------------------------*/
127 
128 class cellDecomposer
129 :
130  public fvMeshFunctionObject
131 {
132  // Private Data
133 
134  //- Parameter dictionary
135  dictionary dict_;
136 
137  //- Name of new mesh
138  word mapRegion_;
139 
140  //- List of field names to interpolate
141  wordRes fieldNames_;
142 
143  //- Tet decomposer
144  autoPtr<tetDecomposer> tetDecompPtr_;
145 
146  //- Map from polyMesh to tet-mesh
147  autoPtr<mapPolyMesh> mapPtr_;
148 
149 
150  // Private Member Functions
151 
152  //- Generate mesh
153  void makeMesh(const dictionary& dict, const word& name);
154 
155  //- Helper function to map the <Type> fields
156  template<class Type>
157  bool mapFieldType() const;
158 
159  //- Helper function to write the <Type> fields
160  template<class Type>
161  bool writeFieldType() const;
162 
163  template<class Type>
164  tmp<GeometricField<Type, fvPatchField, volMesh>>
165  interpolate
166  (
167  const GeometricField<Type, fvPatchField, volMesh>& vf,
168  const fvMesh& sMesh,
169  const labelUList& patchMap,
170  const labelUList& cellMap,
171  const labelUList& faceMap,
172  const bool allowUnmapped
173  ) const;
174 
175 
176 public:
177 
178 
179  //- Runtime type information
180  TypeName("cellDecomposer");
181 
182 
183  // Constructors
184 
185  //- Construct from Time and dictionary
187  (
188  const word& name,
189  const Time& runTime,
190  const dictionary& dict
191  );
192 
193 
194  //- Destructor
195  virtual ~cellDecomposer() = default;
196 
197 
198  // Member Functions
199 
200  //- Read the cellDecomposer data
201  virtual bool read(const dictionary& dict);
202 
203  //- Execute
204  virtual bool execute();
205 
206  //- Write
207  virtual bool write();
208 };
209 
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 } // End namespace functionObjects
214 } // End namespace Foam
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #ifdef NoRepository
219  #include "cellDecomposerTemplates.C"
220 #endif
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #endif
225 
226 // ************************************************************************* //
dictionary dict
Forwards and collection of common volume field types.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
engineTime & runTime
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
const word & name() const noexcept
Return the name of this functionObject.
UList< label > labelUList
A UList of labels.
Definition: UList.H:78
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
cellDecomposer(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
A class for handling words, derived from Foam::string.
Definition: word.H:63
TypeName("cellDecomposer")
Runtime type information.
virtual bool read(const dictionary &dict)
Read the cellDecomposer data.
virtual ~cellDecomposer()=default
Destructor.
Namespace for OpenFOAM.