faMeshTools.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) 2022 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::faMeshTools
28
29Description
30 A collection of tools for operating on an faMesh.
31
32SourceFiles
33 faMeshTools.C
34 faMeshToolsProcAddr.C
35 faMeshToolsTemplates.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef Foam_faMeshTools_H
40#define Foam_faMeshTools_H
41
42#include "faMesh.H"
43#include "areaFieldsFwd.H"
44#include "edgeFieldsFwd.H"
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48namespace Foam
49{
50
51// Forward Declarations
52class mapDistributePolyMesh;
53class writeHandler;
54class polyMesh;
55class IOobject;
56
57/*---------------------------------------------------------------------------*\
58 Class faMeshTools Declaration
59\*---------------------------------------------------------------------------*/
61class faMeshTools
62{
63public:
64
65 //- Unregister the faMesh from its associated polyMesh
66 //- to prevent triggering on polyMesh changes etc.
67 static void unregisterMesh(const faMesh& mesh);
68
69 //- Force creation of everything that might vaguely be used by patches.
70 // This is fairly horrible.
71 static void forceDemandDriven(faMesh& mesh);
72
73
74 //- Read mesh or create dummy mesh (0 faces, >0 patches).
75 // Works in two modes according to masterOnlyReading:
76 // true : create a dummy mesh for all procs
77 // false: checks locally for mesh directories and only creates dummy mesh
78 // if not present
80 (
81 const IOobject& io,
82 const polyMesh& pMesh,
83 const bool masterOnlyReading,
84 const bool verbose = false
85 );
86
87 // Read mesh if available. Otherwise create empty mesh with same non-proc
88 // patches as proc0 mesh. Requires:
89 // - all processors to have all patches (and in same order).
90 // - io.instance() set to facesInstance
92 (
93 const IOobject& io,
94 const polyMesh& pMesh,
95 const bool decompose,
96 const bool verbose = false
97 );
98
99
100 //- Read decompose/reconstruct addressing
102 (
103 const faMesh& mesh,
104 const autoPtr<faMesh>& baseMeshPtr
105 );
106
107 //- Write decompose/reconstruct addressing
108 //
109 // \param mesh
110 // \param faDistMap
111 // \param decompose running in decompose vs reconstruct mode
112 // \param writeHandler file handler
113 // \param procMesh (optional) processor mesh in reconstruct mode
114 //
115 // \note Since the faMesh holds a reference to a polyMesh,
116 // in reconstruct mode it will refer to the base mesh, but
117 // we need a means to proc addressing into the processor locations.
118 // This is the purpose of the additional procMesh reference
119 static void writeProcAddressing
120 (
121 const faMesh& mesh,
122 const mapDistributePolyMesh& faDistMap,
123 const bool decompose,
124 autoPtr<fileOperation>&& writeHandler,
125 const faMesh* procMesh = nullptr
126 );
127
128
129 //- Flatten an edge field into linear addressing
130 // Optionally use primitive patch edge ordering
131 template<class Type>
133 (
135 const bool primitiveOrdering = false
136 );
137};
138
139
140// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141
142} // End namespace Foam
143
144// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145
146#ifdef NoRepository
147 #include "faMeshToolsTemplates.C"
148#endif
149
150// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151
152#endif
153
154// ************************************************************************* //
Forwards and collection of common area field types.
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic GeometricField class.
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 collection of tools for operating on an faMesh.
Definition: faMeshTools.H:61
static mapDistributePolyMesh readProcAddressing(const faMesh &mesh, const autoPtr< faMesh > &baseMeshPtr)
Read decompose/reconstruct addressing.
static void writeProcAddressing(const faMesh &mesh, const mapDistributePolyMesh &faDistMap, const bool decompose, autoPtr< fileOperation > &&writeHandler, const faMesh *procMesh=nullptr)
Write decompose/reconstruct addressing.
static void unregisterMesh(const faMesh &mesh)
Definition: faMeshTools.C:38
static void forceDemandDriven(faMesh &mesh)
Force creation of everything that might vaguely be used by patches.
Definition: faMeshTools.C:50
static tmp< Field< Type > > flattenEdgeField(const GeometricField< Type, faePatchField, edgeMesh > &fld, const bool primitiveOrdering=false)
Flatten an edge field into linear addressing.
static autoPtr< faMesh > newMesh(const IOobject &io, const polyMesh &pMesh, const bool masterOnlyReading, const bool verbose=false)
Read mesh or create dummy mesh (0 faces, >0 patches).
Definition: faMeshTools.C:68
static autoPtr< faMesh > loadOrCreateMesh(const IOobject &io, const polyMesh &pMesh, const bool decompose, const bool verbose=false)
Definition: faMeshTools.C:250
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:100
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A class for managing temporary objects.
Definition: tmp.H:65
dynamicFvMesh & mesh
Forwards for edge field types.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.