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-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::fvMeshTools
29 
30 Description
31  A collection of tools for operating on an fvMesh.
32 
33 SourceFiles
34  fvMeshTools.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef fvMeshTools_H
39 #define fvMeshTools_H
40 
41 #include "fvMesh.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class fvMeshTools Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class fvMeshTools
53 {
54  template<class GeoField>
55  static void addPatchFields
56  (
57  fvMesh&,
58  const dictionary& patchFieldDict,
59  const word& defaultPatchFieldType,
60  const typename GeoField::value_type& defaultPatchValue
61  );
62 
63  //- Set patchFields according to dictionary
64  template<class GeoField>
65  static void setPatchFields
66  (
67  fvMesh& mesh,
68  const label patchi,
69  const dictionary& patchFieldDict
70  );
71 
72  //- Set patchFields to value
73  template<class GeoField>
74  static void setPatchFields
75  (
76  fvMesh& mesh,
77  const label patchi,
78  const typename GeoField::value_type& value
79  );
80 
81  // Remove last patch fields
82  template<class GeoField>
83  static void trimPatchFields(fvMesh&, const label nPatches);
84 
85  template<class GeoField>
86  static void reorderPatchFields(fvMesh&, const labelList& oldToNew);
87 
88  // Remove trailing patches
89  static void trimPatches(fvMesh&, const label nPatches);
90 
91 
92 public:
93 
94  //- Add patch. Inserts patch before all processor patches.
95  // Supply per field the new patchField per field as a
96  // subdictionary or a default type. If validBoundary call is parallel
97  // synced and all add the same patch with same settings.
98  static label addPatch
99  (
100  fvMesh& mesh,
101  const polyPatch& patch,
102  const dictionary& patchFieldDict,
103  const word& defaultPatchFieldType,
104  const bool validBoundary
105  );
106 
107  //- Change patchField on registered fields according to dictionary
108  static void setPatchFields
109  (
110  fvMesh& mesh,
111  const label patchi,
112  const dictionary& patchFieldDict
113  );
114 
115  //- Change patchField to zero on registered fields
116  static void zeroPatchFields(fvMesh& mesh, const label patchi);
117 
118  //- Reorder and remove trailing patches. If validBoundary call is parallel
119  // synced
120  static void reorderPatches
121  (
122  fvMesh&,
123  const labelList& oldToNew,
124  const label nPatches,
125  const bool validBoundary
126  );
127  //- Remove zero sized patches. All but processor patches are
128  // assumed to be present on all processors (so size will be reduced
129  // if validBoundary). Return map from new
130  // to old patches
131  static labelList removeEmptyPatches(fvMesh&, const bool validBoundary);
132 
133  //- Read mesh or create dummy mesh (0 cells, >0 patches). Works in two
134  // modes according to masterOnlyReading:
135  // true : all slaves create dummy mesh
136  // false: checks locally for mesh directories and only creates dummy mesh
137  // if not present
138  static autoPtr<fvMesh> newMesh
139  (
140  const IOobject& io,
141  const bool masterOnlyReading
142  );
143 
144  //- Create additional fv* files
145  static void createDummyFvMeshFiles
146  (
147  const objectRegistry& parent,
148  const word& regionName,
149  const bool verbose = false
150  );
151 };
152 
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 } // End namespace Foam
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #ifdef NoRepository
161  #include "fvMeshToolsTemplates.C"
162 #endif
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::fvMeshTools::zeroPatchFields
static void zeroPatchFields(fvMesh &mesh, const label patchi)
Change patchField to zero on registered fields.
Definition: fvMeshTools.C:243
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fvMeshTools::createDummyFvMeshFiles
static void createDummyFvMeshFiles(const objectRegistry &parent, const word &regionName, const bool verbose=false)
Create additional fv* files.
Definition: fvMeshTools.C:760
nPatches
label nPatches
Definition: readKivaGrid.H:396
Foam::fvMeshTools::removeEmptyPatches
static labelList removeEmptyPatches(fvMesh &, const bool validBoundary)
Remove zero sized patches. All but processor patches are.
Definition: fvMeshTools.C:361
fvMeshToolsTemplates.C
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::fvMeshTools::newMesh
static autoPtr< fvMesh > newMesh(const IOobject &io, const bool masterOnlyReading)
Read mesh or create dummy mesh (0 cells, >0 patches). Works in two.
Definition: fvMeshTools.C:424
Foam::fvMeshTools::reorderPatches
static void reorderPatches(fvMesh &, const labelList &oldToNew, const label nPatches, const bool validBoundary)
Reorder and remove trailing patches. If validBoundary call is parallel.
Definition: fvMeshTools.C:329
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::List< label >
Foam::fvMeshTools::addPatch
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:37
Foam::fvMeshTools
A collection of tools for operating on an fvMesh.
Definition: fvMeshTools.H:51