processorFaMeshes.C
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) 2016-2017 Wikki Ltd
9  Copyright (C) 2022-2023 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 \*---------------------------------------------------------------------------*/
28 
29 #include "processorFaMeshes.H"
30 #include "Time.H"
31 #include "OSspecific.H"
32 
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 
35 void Foam::processorFaMeshes::read()
36 {
37  // Make sure to clear (and hence unregister) any previously loaded meshes
38  // and fields
39 
40  boundaryProcAddressing_.free();
41  faceProcAddressing_.free();
42  edgeProcAddressing_.free();
43  pointProcAddressing_.free();
44  meshes_.free();
45 
46 
47  forAll(fvMeshes_, proci)
48  {
49  // Construct from polyMesh IO information
50  meshes_.emplace_set(proci, fvMeshes_[proci]);
51 
52  // Read the addressing information
53 
54  IOobject ioAddr
55  (
56  "procAddressing",
57  "constant", // Placeholder
59  meshes_[proci].thisDb(),
62  );
63 
64  const auto& runTime = meshes_[proci].thisDb().time();
65  const auto& meshDir = meshes_[proci].meshDir();
66 
67  // pointProcAddressing (faMesh)
68  ioAddr.rename("pointProcAddressing");
69  ioAddr.instance() = runTime.findInstance(meshDir, ioAddr.name());
70  pointProcAddressing_.emplace_set(proci, ioAddr);
71 
72  // edgeProcAddressing (faMesh)
73  ioAddr.rename("edgeProcAddressing");
74  ioAddr.instance() = runTime.findInstance(meshDir, ioAddr.name());
75  edgeProcAddressing_.emplace_set(proci, ioAddr);
76 
77  // faceProcAddressing (faMesh)
78  ioAddr.rename("faceProcAddressing");
79  ioAddr.instance() = runTime.findInstance(meshDir, ioAddr.name());
80  faceProcAddressing_.emplace_set(proci, ioAddr);
81 
82  // boundaryProcAddressing (faMesh)
83  ioAddr.rename("boundaryProcAddressing");
84  ioAddr.instance() = runTime.findInstance(meshDir, ioAddr.name());
85  boundaryProcAddressing_.emplace_set(proci, ioAddr);
86  }
87 }
88 
89 
90 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
91 
92 Foam::processorFaMeshes::processorFaMeshes
93 (
94  const UPtrList<fvMesh>& procFvMeshes
95 )
96 :
97  fvMeshes_(procFvMeshes),
98  meshes_(procFvMeshes.size()),
99  pointProcAddressing_(meshes_.size()),
100  edgeProcAddressing_(meshes_.size()),
101  faceProcAddressing_(meshes_.size()),
102  boundaryProcAddressing_(meshes_.size())
103 {
104  read();
105 }
106 
107 
108 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
109 
111 {
112  IOobject io
113  (
114  "procAddressing",
117  mesh.thisDb()
118  );
119 
120  // procAddressing
121  fileHandler().rm(fileHandler().filePath(io.objectPath()));
122 
123  // pointProcAddressing
124  io.rename("pointProcAddressing");
125  fileHandler().rm(fileHandler().filePath(io.objectPath()));
126 
127  // edgeProcAddressing
128  io.rename("edgeProcAddressing");
129  fileHandler().rm(fileHandler().filePath(io.objectPath()));
130 
131  // faceProcAddressing
132  io.rename("faceProcAddressing");
133  fileHandler().rm(fileHandler().filePath(io.objectPath()));
134 
135  // boundaryProcAddressing
136  io.rename("boundaryProcAddressing");
137  fileHandler().rm(fileHandler().filePath(io.objectPath()));
138 }
139 
140 
141 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:87
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:859
virtual void rename(const word &newName)
Rename the object.
Definition: IOobject.H:677
engineTime & runTime
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler()
Ignore writing from objectRegistry::writeObject()
fileName objectPath() const
The complete path + object name.
Definition: IOobjectI.H:284
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:127
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
Definition: fvMesh.H:376
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
dynamicFvMesh & mesh
static void removeFiles(const faMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
static word meshSubDir
The mesh sub-directory name (usually "faMesh")
Definition: faMesh.H:701
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172