fvMeshTools.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) 2012-2016 OpenFOAM Foundation
9 Copyright (C) 2015-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::fvMeshTools
29
30Description
31 A collection of tools for operating on an fvMesh.
32
33SourceFiles
34 fvMeshTools.C
35 fvMeshToolsProcAddr.C
36 fvMeshToolsTemplates.C
37
38\*---------------------------------------------------------------------------*/
39
40#ifndef Foam_fvMeshTools_H
41#define Foam_fvMeshTools_H
42
43#include "fvMesh.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50// Forward Declarations
51class mapDistributePolyMesh;
52class writeHandler;
53
54/*---------------------------------------------------------------------------*\
55 Class fvMeshTools Declaration
56\*---------------------------------------------------------------------------*/
58class fvMeshTools
59{
60 // Private Member Functions
61
62 template<class GeoField>
63 static void addPatchFields
64 (
65 fvMesh&,
66 const dictionary& patchFieldDict,
67 const word& defaultPatchFieldType,
68 const typename GeoField::value_type& defaultPatchValue
69 );
70
71 //- Set patchFields according to dictionary
72 template<class GeoField>
73 static void setPatchFields
74 (
75 fvMesh& mesh,
76 const label patchi,
77 const dictionary& patchFieldDict
78 );
79
80 //- Set patchFields to value
81 template<class GeoField>
82 static void setPatchFields
83 (
84 fvMesh& mesh,
85 const label patchi,
86 const typename GeoField::value_type& value
87 );
88
89 // Remove last patch fields
90 template<class GeoField>
91 static void trimPatchFields(fvMesh&, const label nPatches);
92
93 template<class GeoField>
94 static void reorderPatchFields(fvMesh&, const labelList& oldToNew);
95
96 // Remove trailing patches
97 static void trimPatches(fvMesh&, const label nPatches);
98
99
100public:
101
102 // Member Functions
103
104 //- Add patch. Inserts patch before all processor patches.
105 // Supply per field the new patchField per field as a
106 // subdictionary or a default type. If validBoundary call is parallel
107 // synced and all add the same patch with same settings.
108 static label addPatch
109 (
110 fvMesh& mesh,
111 const polyPatch& patch,
112 const dictionary& patchFieldDict,
113 const word& defaultPatchFieldType,
114 const bool validBoundary
115 );
116
117 //- Change patchField on registered fields according to dictionary
118 static void setPatchFields
119 (
120 fvMesh& mesh,
121 const label patchi,
122 const dictionary& patchFieldDict
123 );
124
125 //- Change patchField to zero on registered fields
126 static void zeroPatchFields(fvMesh& mesh, const label patchi);
127
128 //- Reorder and remove trailing patches.
129 // Is parallel synced when validBoundary is true
130 static void reorderPatches
131 (
132 fvMesh&,
133 const labelList& oldToNew,
134 const label nPatches,
135 const bool validBoundary
136 );
137
138 //- Remove zero sized patches. All but processor patches are
139 // assumed to be present on all processors (so size will be reduced
140 // if validBoundary). Return map from new
141 // to old patches
142 static labelList removeEmptyPatches(fvMesh&, const bool validBoundary);
143
144
145 //- Set the fvGeometryScheme to basic (to avoid parallel communication)
146 static void setBasicGeometry(fvMesh& mesh);
147
148 //- Read mesh or create dummy mesh (0 cells, >0 patches).
149 //
150 // Works in two modes according to masterOnlyReading:
151 // true : create dummy mesh on all procs
152 // false: checks locally for mesh directories and only creates dummy mesh
153 // if not present
155 (
156 const IOobject& io,
157 const bool masterOnlyReading,
158 const bool verbose = false
159 );
160
161 //- Read mesh if available, or create empty mesh with non-proc as per
162 //- proc0 mesh.
163 // Requires:
164 // - all processors to have all patches (and in same order).
165 // - io.instance() set to facesInstance
167 (
168 const IOobject& io,
169 const bool decompose,
170 const bool verbose = false
171 );
172
173 //- Create additional fvSchemes/fvSolution files
174 static void createDummyFvMeshFiles
175 (
176 const objectRegistry& parent,
177 const word& regionName,
178 const bool verbose = false
179 );
180
181
182 //- Read procAddressing components (reconstructing)
184 (
185 const fvMesh& procMesh,
186 const autoPtr<fvMesh>& baseMeshPtr
187 );
188
189 //- Write addressing if decomposing (1 to many) or reconstructing
190 //- (many to 1)
191 static void writeProcAddressing
192 (
193 const fvMesh& procMesh,
194 const mapDistributePolyMesh& map,
195 const bool decompose,
196 autoPtr<fileOperation>&& writeHandler
197 );
198};
199
200
201// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202
203} // End namespace Foam
204
205// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206
207#ifdef NoRepository
208 #include "fvMeshToolsTemplates.C"
209#endif
210
211// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212
213#endif
214
215// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A collection of tools for operating on an fvMesh.
Definition: fvMeshTools.H:58
static void writeProcAddressing(const fvMesh &procMesh, const mapDistributePolyMesh &map, const bool decompose, autoPtr< fileOperation > &&writeHandler)
static autoPtr< mapDistributePolyMesh > readProcAddressing(const fvMesh &procMesh, const autoPtr< fvMesh > &baseMeshPtr)
Read procAddressing components (reconstructing)
static void reorderPatches(fvMesh &, const labelList &oldToNew, const label nPatches, const bool validBoundary)
Reorder and remove trailing patches.
Definition: fvMeshTools.C:322
static labelList removeEmptyPatches(fvMesh &, const bool validBoundary)
Remove zero sized patches. All but processor patches are.
Definition: fvMeshTools.C:368
static void createDummyFvMeshFiles(const objectRegistry &parent, const word &regionName, const bool verbose=false)
Create additional fvSchemes/fvSolution files.
Definition: fvMeshTools.C:1064
static label addPatch(fvMesh &mesh, const polyPatch &patch, const dictionary &patchFieldDict, const word &defaultPatchFieldType, const bool validBoundary)
Add patch. Inserts patch before all processor patches.
Definition: fvMeshTools.C:43
static autoPtr< fvMesh > newMesh(const IOobject &io, const bool masterOnlyReading, const bool verbose=false)
Read mesh or create dummy mesh (0 cells, >0 patches).
Definition: fvMeshTools.C:451
static void setBasicGeometry(fvMesh &mesh)
Set the fvGeometryScheme to basic (to avoid parallel communication)
Definition: fvMeshTools.C:430
static autoPtr< fvMesh > loadOrCreateMesh(const IOobject &io, const bool decompose, const bool verbose=false)
Definition: fvMeshTools.C:734
static void zeroPatchFields(fvMesh &mesh, const label patchi)
Change patchField to zero on registered fields.
Definition: fvMeshTools.C:228
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Registry of regIOobjects.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
Foam::word regionName(Foam::polyMesh::defaultRegion)
const label nPatches
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.