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-------------------------------------------------------------------------------
10License
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
33namespace Foam
34{
36}
37
38
39// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40
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
60(
61 const IOobject& io,
63)
64:
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
85(
86 const IOobject& io,
87 const lduMesh& mesh
88)
89:
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 totalSize() const
The total addressed size.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:71
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:106
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition: lduMesh.H:63
An assembly of lduMatrix that is specific inter-region coupling through mapped patches.
void updateMaps(const UPtrList< lduMesh > &)
Size maps.
label findNbrMeshId(const polyPatch &pp, const label iMesh) const
Find nrb mesh Id for mapped patches.
const UPtrList< lduMesh > & meshes() const
Return fvMeshes.
Simplest concrete lduMesh that stores the addressing needed by lduMatrix.
virtual label comm() const
Return communicator used for parallel communication.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
virtual word neighbRegionID() const
Return neighbour region name.
Definition: polyPatch.H:353
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333