lduPrimitiveMeshAssembly.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) 2019 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "mappedPatchBase.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(lduPrimitiveMeshAssembly, 0);
36 }
37 
38 
39 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40 
41 Foam::label Foam::lduPrimitiveMeshAssembly::totalSize
42 (
43  const UPtrList<lduMesh>& meshes
44 )
45 {
46  label tot = 0;
47 
48  forAll(meshes, meshi)
49  {
50  tot += meshes[meshi].lduAddr().size();
51  }
52 
53  return tot;
54 }
55 
56 
57 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
58 
59 Foam::lduPrimitiveMeshAssembly::lduPrimitiveMeshAssembly
60 (
61  const IOobject& io,
63 )
64 :
65  regIOobject(io),
66  lduPrimitiveMesh(totalSize(meshes)),
67  meshes_(meshes)
68 {
69  forAll(meshes, meshi)
70  {
71  if (meshes[meshi].comm() != comm())
72  {
74  << "Communicator " << meshes[meshi].comm()
75  << " at index " << meshi
76  << " differs between meshes " << nl;
77  }
78  }
79 
81 }
82 
83 
84 Foam::lduPrimitiveMeshAssembly::lduPrimitiveMeshAssembly
85 (
86  const IOobject& io,
87  const lduMesh& mesh
88 )
89 :
90  regIOobject(io),
91  lduPrimitiveMesh(mesh.lduAddr().size()),
92  meshes_(1)
93 {
94  meshes_.set(0, const_cast<lduMesh*>(&mesh));
95  updateMaps(meshes_);
96 }
97 
98 // * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
99 
100 
102 (
104 )
105 {
106  const label nMeshes = meshes.size();
107  patchMap_.setSize(nMeshes);
108  patchLocalToGlobalMap_.setSize(nMeshes);
109  faceMap_.setSize(nMeshes);
110  faceBoundMap_.setSize(nMeshes);
111  cellBoundMap_.setSize(nMeshes);
112 
113  facePatchFaceMap_.setSize(nMeshes);
114 
115  // Determine cellOffset and faceOffset
116  cellOffsets_.setSize(1+nMeshes);
117  cellOffsets_[0] = 0;
118  for (label meshi=0; meshi < nMeshes; ++meshi)
119  {
120  cellOffsets_[meshi+1] =
121  cellOffsets_[meshi] + meshes[meshi].lduAddr().size();
122  }
123 
124  for (label i=0; i < nMeshes; ++i)
125  {
126  patchMap_[i].setSize(meshes_[i].interfaces().size(), -1);
127  patchLocalToGlobalMap_[i].setSize(patchMap_[i].size(), -1);
128 
129  faceBoundMap_[i].setSize(patchMap_[i].size());
130  cellBoundMap_[i].setSize(patchMap_[i].size());
131  facePatchFaceMap_[i].setSize(patchMap_[i].size());
132  }
133 }
134 
135 
137 (
138  const polyPatch& pp,
139  const label iMesh
140 ) const
141 {
142  if (pp.neighbRegionID() != "none")
143  {
144  forAll(meshes_, meshi)
145  {
146  if (meshes_[meshi].thisDb().name() == pp.neighbRegionID())
147  {
148  return meshi;
149  }
150  }
151  }
152  else
153  {
154  return iMesh;
155  }
156  return -1;
157 }
158 
159 // ************************************************************************* //
label findNbrMeshId(const polyPatch &pp, const label iMesh) const
Find nrb mesh Id for mapped patches.
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
const UPtrList< lduMesh > & meshes() const
Return fvMeshes.
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:106
virtual label comm() const
Return communicator used for parallel communication.
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
Simplest concrete lduMesh that stores the addressing needed by lduMatrix.
static const lduMesh & mesh(const lduMesh &mesh0, const PtrList< lduPrimitiveMesh > &otherMeshes, const label meshI)
Select either mesh0 (meshI is 0) or otherMeshes[meshI-1].
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:66
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
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Namespace for OpenFOAM.
void updateMaps(const UPtrList< lduMesh > &)
Size maps.