fvFieldReconstructor.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
6  \\/ M anipulation |
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 \*---------------------------------------------------------------------------*/
25 
26 #include "fvFieldReconstructor.H"
27 #include "processorCyclicFvPatch.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 Foam::label Foam::fvFieldReconstructor::completePatchID
32 (
33  const label proci,
34  const label procPatchi
35 ) const
36 {
37  const fvPatch& procPatch = procMeshes_[proci].boundary()[procPatchi];
38 
39  if (procPatchi < completeMesh_.boundary().size())
40  {
41  return procPatchi;
42  }
43  else if (isA<processorCyclicFvPatch>(procPatch))
44  {
45  return
46  refCast<const processorCyclicFvPatch>(procPatch)
47  .referPatchIndex();
48  }
49  else
50  {
51  return -1;
52  }
53 }
54 
55 
56 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
57 
59 (
60  const fvMesh& completeMesh,
61  const PtrList<fvMesh>& procMeshes,
62  const labelListList& faceProcAddressing,
63  const labelListList& cellProcAddressing,
64  const PtrList<surfaceLabelField::Boundary>& faceProcAddressingBf
65 )
66 :
67  completeMesh_(completeMesh),
68  procMeshes_(procMeshes),
69  faceProcAddressing_(faceProcAddressing),
70  cellProcAddressing_(cellProcAddressing),
71  faceProcAddressingBf_(faceProcAddressingBf)
72 {
73  forAll(procMeshes_, proci)
74  {
75  const fvMesh& procMesh = procMeshes_[proci];
76 
77  if
78  (
79  faceProcAddressing[proci].size() != procMesh.nFaces()
80  || cellProcAddressing[proci].size() != procMesh.nCells()
81  )
82  {
84  << "Size of maps does not correspond to size of mesh"
85  << " for processor " << proci << endl
86  << "faceProcAddressing : " << faceProcAddressing[proci].size()
87  << " nFaces : " << procMesh.nFaces() << endl
88  << "cellProcAddressing : " << cellProcAddressing[proci].size()
89  << " nCell : " << procMesh.nCells() << endl
90  << " nFaces : " << procMesh.boundary().size()
91  << exit(FatalError);
92  }
93  }
94 }
95 
96 
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 
99 bool Foam::fvFieldReconstructor::reconstructs
100 (
101  const IOobjectList& objects,
102  const HashSet<word>& selectedFields
103 )
104 {
105  bool result = false;
106 
107  #define DO_FV_FIELDS_TYPE(Type, nullArg) \
108  result = result \
109  || reconstructs<VolField<Type>::Internal>(objects, selectedFields) \
110  || reconstructs<VolField<Type>>(objects, selectedFields) \
111  || reconstructs<SurfaceField<Type>>(objects, selectedFields);
112  FOR_ALL_FIELD_TYPES(DO_FV_FIELDS_TYPE)
113  #undef DO_FV_FIELDS_TYPE
114 
115  return result;
116 }
117 
118 
119 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
fvFieldReconstructor(const fvMesh &mesh, const PtrList< fvMesh > &procMeshes, const labelListList &faceProcAddressing, const labelListList &cellProcAddressing, const PtrList< surfaceLabelField::Boundary > &faceProcAddressingBf)
Construct from components.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:857
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
error FatalError
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
objects