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 
80  updateMaps(meshes);
81 }
82 
83 
84 Foam::lduPrimitiveMeshAssembly::lduPrimitiveMeshAssembly
85 (
86  const IOobject& io,
87  const lduMesh& mesh
88 )
89 :
90  regIOobject(io),
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 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::lduPrimitiveMeshAssembly::updateMaps
void updateMaps(const UPtrList< lduMesh > &)
Size maps.
Definition: lduPrimitiveMeshAssembly.C:102
Foam::lduAddressing::size
label size() const
Return number of equations.
Definition: lduAddressing.H:171
Foam::polyPatch::neighbRegionID
virtual word neighbRegionID() const
Return neighbour region name.
Definition: polyPatch.H:350
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::lduPrimitiveMeshAssembly::meshes
const UPtrList< lduMesh > & meshes() const
Return fvMeshes.
Definition: lduPrimitiveMeshAssembly.H:214
lduPrimitiveMeshAssembly.H
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::fvMesh::lduAddr
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
Definition: fvMesh.C:691
meshes
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
Foam::PtrList::setSize
void setSize(const label newLen)
Same as resize()
Definition: PtrList.H:151
Foam::UPtrList
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:62
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::lduPrimitiveMesh
Simplest concrete lduMesh that stores the addressing needed by lduMatrix.
Definition: lduPrimitiveMesh.H:52
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::lduPrimitiveMeshAssembly::findNbrMeshId
label findNbrMeshId(const polyPatch &pp, const label iMesh) const
Find nrb mesh Id for mapped patches.
Definition: lduPrimitiveMeshAssembly.C:137
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:328
Foam::lduMesh
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition: lduMesh.H:62
mappedPatchBase.H