fvFieldReconstructor.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2022 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 "fvFieldReconstructor.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
40 Foam::fvFieldReconstructor::fvFieldReconstructor
41 (
42  fvMesh& mesh,
43  const PtrList<fvMesh>& procMeshes,
44  const PtrList<labelIOList>& faceProcAddressing,
45  const PtrList<labelIOList>& cellProcAddressing,
46  const PtrList<labelIOList>& boundaryProcAddressing
47 )
48 :
49  mesh_(mesh),
50  procMeshes_(procMeshes),
51  faceProcAddressing_(faceProcAddressing),
52  cellProcAddressing_(cellProcAddressing),
53  boundaryProcAddressing_(boundaryProcAddressing),
54  nReconstructed_(0)
55 {
56  forAll(procMeshes_, proci)
57  {
58  const fvMesh& procMesh = procMeshes_[proci];
59  if
60  (
61  faceProcAddressing[proci].size() != procMesh.nFaces()
62  || cellProcAddressing[proci].size() != procMesh.nCells()
63  || boundaryProcAddressing[proci].size() != procMesh.boundary().size()
64  )
65  {
67  << "Size of maps does not correspond to size of mesh"
68  << " for processor " << proci << endl
69  << "faceProcAddressing : " << faceProcAddressing[proci].size()
70  << " nFaces : " << procMesh.nFaces() << endl
71  << "cellProcAddressing : " << cellProcAddressing[proci].size()
72  << " nCell : " << procMesh.nCells() << endl
73  << "boundaryProcAddressing : "
74  << boundaryProcAddressing[proci].size()
75  << " nFaces : " << procMesh.boundary().size()
76  << exit(FatalError);
77  }
78  }
79 }
80 
81 
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 
85 (
86  const IOobjectList& objects,
87  const wordRes& selected
88 )
89 {
90  label nTotal = 0;
91 
92  do
93  {
94  #undef doLocalCode
95  #define doLocalCode(Method) \
96  { \
97  nTotal += this->Method <scalar> (objects, selected); \
98  nTotal += this->Method <vector> (objects, selected); \
99  nTotal += this->Method <sphericalTensor> (objects, selected); \
100  nTotal += this->Method <symmTensor> (objects, selected); \
101  nTotal += this->Method <tensor> (objects, selected); \
102  }
103 
104  doLocalCode(reconstructInternalFields);
105  doLocalCode(reconstructVolumeFields);
106  doLocalCode(reconstructSurfaceFields);
107 
108  #undef doLocalCode
109  }
110  while (false);
111 
112  return nTotal;
113 }
114 
115 
116 // ************************************************************************* //
Foam::surfaceFields.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
#define doLocalCode(Method)
label nFaces() const noexcept
Number of mesh faces.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
dynamicFvMesh & mesh
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:106
label reconstructAllFields(const IOobjectList &objects, const wordRes &selectedFields=wordRes())
Reconstruct all known field types.
label nCells() const noexcept
Number of mesh cells.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
static int verbose_
Output verbosity when writing.
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Definition: fvMesh.H:395