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-2022 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 refCast<const processorCyclicFvPatch>(procPatch).referPatchID();
46  }
47  else
48  {
49  return -1;
50  }
51 }
52 
53 
54 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55 
57 (
58  const fvMesh& completeMesh,
59  const PtrList<fvMesh>& procMeshes,
60  const labelListList& faceProcAddressing,
61  const labelListList& cellProcAddressing,
62  const PtrList<surfaceLabelField::Boundary>& faceProcAddressingBf
63 )
64 :
65  completeMesh_(completeMesh),
66  procMeshes_(procMeshes),
67  faceProcAddressing_(faceProcAddressing),
68  cellProcAddressing_(cellProcAddressing),
69  faceProcAddressingBf_(faceProcAddressingBf),
70  nReconstructed_(0)
71 {
72  forAll(procMeshes_, proci)
73  {
74  const fvMesh& procMesh = procMeshes_[proci];
75 
76  if
77  (
78  faceProcAddressing[proci].size() != procMesh.nFaces()
79  || cellProcAddressing[proci].size() != procMesh.nCells()
80  )
81  {
83  << "Size of maps does not correspond to size of mesh"
84  << " for processor " << proci << endl
85  << "faceProcAddressing : " << faceProcAddressing[proci].size()
86  << " nFaces : " << procMesh.nFaces() << endl
87  << "cellProcAddressing : " << cellProcAddressing[proci].size()
88  << " nCell : " << procMesh.nCells() << endl
89  << " nFaces : " << procMesh.boundary().size()
90  << exit(FatalError);
91  }
92  }
93 }
94 
95 
96 // ************************************************************************* //
#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:893
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
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:251
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
error FatalError