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 | Copyright (C) 2012-2014 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::fvMeshTools
26 
27 Description
28  A collection of tools for operating on an fvMesh.
29 
30 SourceFiles
31  fvMeshTools.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef fvMeshTools_H
36 #define fvMeshTools_H
37 
38 #include "fvMesh.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class fvMeshTools Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 class fvMeshTools
50 {
51  template<class GeoField>
52  static void addPatchFields
53  (
54  fvMesh&,
55  const dictionary& patchFieldDict,
56  const word& defaultPatchFieldType,
57  const typename GeoField::value_type& defaultPatchValue
58  );
59 
60  //- Set patchFields according to dictionary
61  template<class GeoField>
62  static void setPatchFields
63  (
64  fvMesh& mesh,
65  const label patchI,
66  const dictionary& patchFieldDict
67  );
68 
69  //- Set patchFields to value
70  template<class GeoField>
71  static void setPatchFields
72  (
73  fvMesh& mesh,
74  const label patchI,
75  const typename GeoField::value_type& value
76  );
77 
78  // Remove last patch fields
79  template<class GeoField>
80  static void trimPatchFields(fvMesh&, const label nPatches);
81 
82  template<class GeoField>
83  static void reorderPatchFields(fvMesh&, const labelList& oldToNew);
84 
85  // Remove trialing patches
86  static void trimPatches(fvMesh&, const label nPatches);
87 
88 
89 public:
90 
91  //- Add patch. Inserts patch before all processor patches.
92  // Supply per field the new patchField per field as a
93  // subdictionary or a default type. If validBoundary call is parallel
94  // synced and all add the same patch with same settings.
95  static label addPatch
96  (
97  fvMesh& mesh,
98  const polyPatch& patch,
99  const dictionary& patchFieldDict,
100  const word& defaultPatchFieldType,
101  const bool validBoundary
102  );
103 
104  //- Change patchField on registered fields according to dictionary
105  static void setPatchFields
106  (
107  fvMesh& mesh,
108  const label patchI,
109  const dictionary& patchFieldDict
110  );
111 
112  //- Change patchField to zero on registered fields
113  static void zeroPatchFields(fvMesh& mesh, const label patchI);
114 
115  //- Reorder and remove trailing patches. If validBoundary call is parallel
116  // synced
117  static void reorderPatches
118  (
119  fvMesh&,
120  const labelList& oldToNew,
121  const label nPatches,
122  const bool validBoundary
123  );
124 
125  //- Remove zero sized patches. All but processor patches are
126  // assumed to be present on all processors (so size will be reduced
127  // if validBoundary). Return map from new
128  // to old patches
129  static labelList removeEmptyPatches(fvMesh&, const bool validBoundary);
130 
131  //- Read mesh or create dummy mesh (0 cells, >0 patches). Works in two
132  // modes according to masterOnlyReading:
133  // true : all slaves create dummy mesh
134  // false: checks locally for mesh directories and only creates dummy mesh
135  // if not present
136  static autoPtr<fvMesh> newMesh
137  (
138  const IOobject& io,
139  const bool masterOnlyReading
140  );
141 };
142 
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 } // End namespace Foam
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 #ifdef NoRepository
151 # include "fvMeshToolsTemplates.C"
152 #endif
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 #endif
157 
158 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvMeshTools::addPatchFields
static void addPatchFields(fvMesh &, const dictionary &patchFieldDict, const word &defaultPatchFieldType, const typename GeoField::value_type &defaultPatchValue)
Definition: fvMeshToolsTemplates.C:34
nPatches
label nPatches
Definition: readKivaGrid.H:402
Foam::fvMeshTools::removeEmptyPatches
static labelList removeEmptyPatches(fvMesh &, const bool validBoundary)
Remove zero sized patches. All but processor patches are.
Definition: fvMeshTools.C:359
Foam::fvMeshTools::zeroPatchFields
static void zeroPatchFields(fvMesh &mesh, const label patchI)
Change patchField to zero on registered fields.
Definition: fvMeshTools.C:241
Foam::fvMeshTools::trimPatches
static void trimPatches(fvMesh &, const label nPatches)
Definition: fvMeshTools.C:277
fvMeshToolsTemplates.C
Foam::fvMeshTools::reorderPatchFields
static void reorderPatchFields(fvMesh &, const labelList &oldToNew)
Definition: fvMeshToolsTemplates.C:171
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::fvMeshTools::trimPatchFields
static void trimPatchFields(fvMesh &, const label nPatches)
Definition: fvMeshToolsTemplates.C:153
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
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:422
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:327
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
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:35
Foam::fvMeshTools::setPatchFields
static void setPatchFields(fvMesh &mesh, const label patchI, const dictionary &patchFieldDict)
Set patchFields according to dictionary.
Definition: fvMeshToolsTemplates.C:89
Foam::fvMeshTools
A collection of tools for operating on an fvMesh.
Definition: fvMeshTools.H:48