Loading...
Searching...
No Matches
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-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::functionObjects::cellDecomposer
28
29Group
30 grpFieldFunctionObjects
31
32Description
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 The decomposition can be full (all cells) or partial (a cellSet). The
38 decomposition can be done in different ways, see the \c decomposeType
39 description below.
40
41 The mapping is done via nearest-neighbour interpolation. The mapped fields
42 are written to the time directory of the original mesh. The mapped fields
43 have the same name as the input fields, but with a \c _decomposed suffix.
44
45 The mapping tolerates cells that cannot be mapped, e.g. if the cell centre
46 of a cell in the decomposed mesh lies outside the original mesh. The
47 unmapped cells get a value of zero, and a warning is issued.
48
49 Operands:
50 \table
51 Operand | Type | Location
52 input | {vol,surface}<Type>Field | <time>/inputFields
53 output file | - | -
54 output field | {vol,surface}<Type>Field | <time>/outputField
55 \endtable
56
57 where \c Type can be one of:
58 \c Scalar, \c Vector, \c SphericalTensor, \c SymmTensor, or \c Tensor.
59
60Usage
61 Minimal example by using \c system/controlDict.functions:
62 \verbatim
63 cellDecomposerFO
64 {
65 // Mandatory entries
66 type cellDecomposer;
67 libs (fieldFunctionObjects);
68 fields (<wordRes>); // (<field1> <field2> ... <fieldN>);
69 mapRegion <word>; // myTetMesh;
70 decomposeType <word>; // polyhedral;
71 selectionMode <word>; //all;
72
73 // Inherited entries
74 ...
75 }
76 \endverbatim
77
78 where the entries mean:
79 \table
80 Property | Description | Type | Reqd | Deflt
81 type | Type name: cellDecomposer | word | yes | -
82 libs | Library name: fieldFunctionObjects | word | yes | -
83 fields | Names of operand fields | wordRes | yes | -
84 cacheDecomposition | Cache the generated mesh | bool | no | false
85 mapRegion | Name of region to map to | word | yes | -
86 decomposeType | How to decompose cells | word | yes | -
87 selectionMode | How to select cells (see fvOption)| word | yes | -
88 \endtable
89
90 The inherited entries are elaborated in:
91 - \link functionObject.H \endlink
92
93 decomposeType:
94
95 - faceCentre : decompose cells into tets using face centre and cell centre.
96 (hex becomes 6*4 tets)
97 - faceDiagonal : decompose cells into tets using face diagonal, similar
98 to implicit decomposition inside lagrangian tracking.
99 (hex becomes 6*2 tets)
100 - pyramid : keep faces intact but create (polygonal-base) pyramids using
101 cell centre (hex becomes 6 pyramids)
102 - faceDiagonalQuads : like faceDiagonal but split faces into quads and
103 triangles instead of just triangles
104 - polyhedral : like faceDiagonalQuads but only decompose non-hex/prism/tet
105 cells in selected set. Used to convert polyhedral mesh into
106 'simple' mesh.
107
108 Note: cacheDecomposition will
109 - keep the mesh and maps
110 - not update the points on the mesh
111 It will not be correct if the selectionMode varies over time or if the
112 geometry of the mapping is used (e.g. old face areas/volumes).
113
114 The inherited entries are elaborated in:
115 - \link functionObject.H \endlink
116
117See also
118 - Foam::functionObjects::mapFields
119
120SourceFiles
121 cellDecomposer.C
122
123\*---------------------------------------------------------------------------*/
124
125#ifndef Foam_functionObjects_cellDecomposer_H
126#define Foam_functionObjects_cellDecomposer_H
127
128#include "fvMeshFunctionObject.H"
129#include "volFieldsFwd.H"
130
131// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132
133namespace Foam
134{
135
136// Forward Declarations
137class tetDecomposer;
138class mapPolyMesh;
139
140namespace functionObjects
141{
142
143/*---------------------------------------------------------------------------*\
144 Class cellDecomposer Declaration
145\*---------------------------------------------------------------------------*/
146
147class cellDecomposer
148:
150{
151 // Private Data
152
153 //- Parameter dictionary
154 dictionary dict_;
155
156 //- Name of new mesh
157 word mapRegion_;
158
159 //- List of field names to interpolate
160 wordRes fieldNames_;
161
162 //- Whether to cache the decomposition
163 bool cacheDecomposition_;
164
165 //- Tet decomposer
166 autoPtr<tetDecomposer> tetDecompPtr_;
167
168 //- Map from polyMesh to tet-mesh
169 autoPtr<mapPolyMesh> mapPtr_;
170
171
172 // Private Member Functions
173
174 //- Generate mesh
175 void makeMesh(const dictionary& dict, const word& name);
176
177 //- Helper function to map the <Type> fields
178 template<class Type>
179 bool mapFieldType() const;
180
181 //- Helper function to write the <Type> fields
182 template<class Type>
183 bool writeFieldType() const;
184
185 //- Interpolates a given volumetric field onto a new mesh using
186 //- provided mapping information.
187 template<class Type>
188 tmp<GeometricField<Type, fvPatchField, volMesh>>
189 interpolate
190 (
191 const GeometricField<Type, fvPatchField, volMesh>& vf,
192 const fvMesh& sMesh,
193 const labelUList& patchMap,
194 const labelUList& cellMap,
195 const labelUList& faceMap,
196 const bool allowUnmapped
197 ) const;
198
199
200public:
201
202
203 //- Runtime type information
204 TypeName("cellDecomposer");
205
207 // Constructors
208
209 //- Construct from name, Time and dictionary
211 (
212 const word& name,
213 const Time& runTime,
214 const dictionary& dict
215 );
216
217
218 //- Destructor
219 virtual ~cellDecomposer() = default;
220
221
222 // Member Functions
223
224 //- Read the function-object dictionary
225 virtual bool read(const dictionary& dict);
226
227 //- Execute the function-object operations
228 virtual bool execute();
229
230 //- Write the function-object results
231 virtual bool write();
232};
233
234
235// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236
237} // End namespace functionObjects
238} // End namespace Foam
239
240// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241
242#ifdef NoRepository
244#endif
245
246// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247
248#endif
249
250// ************************************************************************* //
Generic GeometricField class.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const word & name() const noexcept
Return the name of this functionObject.
Maps input fields from local mesh to a secondary mesh at runtime.
TypeName("cellDecomposer")
Runtime type information.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
cellDecomposer(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
virtual ~cellDecomposer()=default
Destructor.
virtual bool execute()
Execute the function-object operations.
virtual bool write()
Write the function-object results.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Decomposes polyMesh into tets (or pyramids).
A class for managing temporary objects.
Definition tmp.H:75
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
A class for handling words, derived from Foam::string.
Definition word.H:66
engineTime & runTime
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
UList< label > labelUList
A UList of labels.
Definition UList.H:75
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68
Forwards and collection of common volume field types.