assemblyFaceAreaPairGAMGAgglomeration.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) 2018-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 "lduMatrix.H"
32 #include "surfaceFields.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(assemblyFaceAreaPairGAMGAgglomeration, 0);
39 
41  (
42  GAMGAgglomeration,
43  assemblyFaceAreaPairGAMGAgglomeration,
44  lduMatrix
45  );
46 
48  (
49  GAMGAgglomeration,
50  assemblyFaceAreaPairGAMGAgglomeration,
51  geometry
52  );
53 }
54 
55 
56 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * * //
57 
60 {}
61 
62 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63 
66 (
67  const lduMatrix& matrix,
68  const dictionary& controlDict
69 )
70 :
72 {
73  const lduMesh& ldumesh = matrix.mesh();
74 
75  if (isA<lduPrimitiveMeshAssembly>(ldumesh))
76  {
78  refCast<const lduPrimitiveMeshAssembly>(ldumesh);
79 
80  vectorField faceAreas(mesh.lduAddr().upperAddr().size(), Zero);
81 
82  const labelListList& faceMap = mesh.faceMap();
83 
84  for (label i=0; i < mesh.meshes().size(); ++i)
85  {
86  const fvMesh& m = refCast<const fvMesh>(mesh.meshes()[i]);
87  const labelList& subFaceMap = faceMap[i];
88  const vectorField& areas = m.Sf().internalField();
89 
90  forAll(subFaceMap, facei)
91  {
92  faceAreas[subFaceMap[facei]] = areas[facei];
93  }
94 
95  const polyBoundaryMesh& patches = m.boundaryMesh();
96 
97  // Fill faceAreas for new faces
98  forAll(patches, patchI)
99  {
100  const polyPatch& pp = patches[patchI];
101  label globalPatchID = mesh.patchMap()[i][patchI];
102 
103  if (globalPatchID == -1)
104  {
105  if (pp.masterImplicit())
106  {
107  const vectorField& sf = m.boundary()[patchI].Sf();
108 
109  if (isA<cyclicAMIPolyPatch>(pp))
110  {
111  const cyclicAMIPolyPatch& mpp =
112  refCast<const cyclicAMIPolyPatch>(pp);
113 
114  const scalarListList& srcWeight =
115  mpp.AMI().srcWeights();
116 
117  label subFaceI = 0;
118  forAll(pp.faceCells(), faceI)
119  {
120  const scalarList& w = srcWeight[faceI];
121 
122  for(label j=0; j<w.size(); j++)
123  {
124  const label globalFaceI =
125  mesh.faceBoundMap()[i][patchI][subFaceI];
126 
127  if (globalFaceI != -1)
128  {
129  faceAreas[globalFaceI] = w[j]*sf[faceI];
130  }
131  subFaceI++;
132  }
133  }
134  }
135  else if (isA<cyclicACMIPolyPatch>(pp))
136  {
137  const cyclicACMIPolyPatch& mpp =
138  refCast<const cyclicACMIPolyPatch>(pp);
139 
140  const scalarListList& srcWeight =
141  mpp.AMI().srcWeights();
142 
143  const scalarField& mask = mpp.mask();
144  const scalar tol = mpp.tolerance();
145  label subFaceI = 0;
146  forAll(mask, faceI)
147  {
148  const scalarList& w = srcWeight[faceI];
149 
150  for(label j=0; j<w.size(); j++)
151  {
152  if (mask[faceI] > tol)
153  {
154  const label globalFaceI =
155  mesh.faceBoundMap()[i]
156  [patchI][subFaceI];
157 
158  faceAreas[globalFaceI] = w[j]*sf[faceI];
159  }
160  subFaceI++;
161  }
162  }
163  }
164  else
165  {
166  forAll(pp.faceCells(), faceI)
167  {
168  const label globalFaceI =
169  mesh.faceBoundMap()[i][patchI][faceI];
170 
171  if (globalFaceI != -1)
172  {
173  faceAreas[globalFaceI] = sf[faceI];
174  }
175  }
176  }
177  }
178  }
179  }
180  }
181 
183  (
184  mesh,
185  mag
186  (
188  (
189  faceAreas/sqrt(mag(faceAreas)),
190  vector(1, 1.01, 1.02)
191  )
192  )
193  );
194  }
195  else
196  {
197  // Revert to faceAreaPairGAMGAgglomeration
198  const fvMesh& fvmesh = refCast<const fvMesh>(matrix.mesh());
199 
201  (
202  matrix.mesh(),
203  mag
204  (
206  (
207  fvmesh.Sf().primitiveField()
208  /sqrt(fvmesh.magSf().primitiveField()),
209  vector(1, 1.01, 1.02)
210  //vector::one
211  )
212  )
213  );
214  }
215 }
216 
217 
220 (
221  const lduMatrix& matrix,
222  const scalarField& cellVolumes,
223  const vectorField& faceAreas,
224  const dictionary& controlDict
225 )
226 :
227  pairGAMGAgglomeration(matrix.mesh(), controlDict)
228 {
230  (
231  matrix.mesh(),
232  mag
233  (
235  (
236  faceAreas/sqrt(mag(faceAreas)),
237  vector(1, 1.01, 1.02)
238  )
239  )
240  );
241 }
242 
243 
244 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::polyPatch::masterImplicit
virtual bool masterImplicit() const
Definition: polyPatch.H:339
Foam::scalarListList
List< scalarList > scalarListList
A List of scalarList.
Definition: scalarList.H:63
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:46
Foam::scalarList
List< scalar > scalarList
A List of scalars.
Definition: scalarList.H:61
Foam::assemblyFaceAreaPairGAMGAgglomeration::assemblyFaceAreaPairGAMGAgglomeration
assemblyFaceAreaPairGAMGAgglomeration(const lduMatrix &matrix, const dictionary &controlDict)
Definition: assemblyFaceAreaPairGAMGAgglomeration.C:59
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeTopological.C:87
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:59
Foam::cmptMultiply
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::Zero
static constexpr const zero Zero
Definition: zero.H:131
Foam::lduMatrix
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Definition: lduMatrix.H:79
Foam::GeometricField::primitiveField
const Internal::FieldType & primitiveField() const
Definition: GeometricFieldI.H:46
Foam::cyclicACMIPolyPatch::tolerance
static scalar tolerance()
Definition: cyclicACMIPolyPatchI.H:58
Foam::GAMGAgglomeration::faceMap
const labelListList & faceMap(const label fineLeveli) const
Definition: GAMGAgglomeration.C:552
Foam::pairGAMGAgglomeration::agglomerate
void agglomerate(const lduMesh &mesh, const scalarField &faceWeights)
Definition: pairGAMGAgglomerate.C:27
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Definition: polyMesh.H:440
surfaceFields.H
Foam::surfaceFields.
lduMatrix.H
Foam::GeometricField::internalField
const Internal & internalField() const
Definition: GeometricFieldI.H:36
Foam::lduAddressing::upperAddr
virtual const labelUList & upperAddr() const =0
Foam::GAMGAgglomeration::size
label size() const
Definition: GAMGAgglomeration.H:321
forAll
#define forAll(list, i)
Definition: stdFoam.H:349
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:48
lduPrimitiveMeshAssembly.H
Foam::Field
Generic templated field type.
Definition: Field.H:59
Foam::fvMesh::magSf
const surfaceScalarField & magSf() const
Definition: fvMeshGeometry.C:323
Foam::MeshObject< lduMesh, GeometricMeshObject, GAMGAgglomeration >::mesh
const lduMesh & mesh() const
Definition: MeshObject.H:118
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:64
Foam::fvMesh::lduAddr
virtual const lduAddressing & lduAddr() const
Definition: fvMesh.C:684
controlDict
runTime controlDict().readEntry("adjustTimeStep"
Definition: debug.C:139
assemblyFaceAreaPairGAMGAgglomeration.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:81
Foam
Definition: atmBoundaryLayer.C:26
Foam::polyPatch::faceCells
const labelUList & faceCells() const
Definition: polyPatch.C:364
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:47
Foam::fvMesh::boundary
const fvBoundaryMesh & boundary() const
Definition: fvMesh.C:678
Foam::cyclicAMIPolyPatch::AMI
const AMIPatchToPatchInterpolation & AMI() const
Definition: cyclicAMIPolyPatch.C:970
Foam::assemblyFaceAreaPairGAMGAgglomeration::~assemblyFaceAreaPairGAMGAgglomeration
~assemblyFaceAreaPairGAMGAgglomeration()
Definition: assemblyFaceAreaPairGAMGAgglomeration.C:52
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:137
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::lduMatrix::mesh
const lduMesh & mesh() const
Definition: lduMatrix.H:562
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:59
Foam::pairGAMGAgglomeration
Agglomerate using the pair algorithm.
Definition: pairGAMGAgglomeration.H:47
Foam::UList::size
void size(const label n)
Definition: UList.H:110
Foam::cyclicACMIPolyPatch
Cyclic patch for Arbitrarily Coupled Mesh Interface (ACMI).
Definition: cyclicACMIPolyPatch.H:74
Foam::cyclicACMIPolyPatch::mask
const scalarField & mask() const
Definition: cyclicACMIPolyPatchI.H:47
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::lduMesh::lduAddr
virtual const lduAddressing & lduAddr() const =0
Foam::lduPrimitiveMeshAssembly
An assembly of lduMatrix that is specific inter-region coupling through mapped patches.
Definition: lduPrimitiveMeshAssembly.H:48
Foam::lduMesh
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition: lduMesh.H:56
Foam::AMIInterpolation::srcWeights
const scalarListList & srcWeights() const
Definition: AMIInterpolationI.H:134
Foam::cyclicAMIPolyPatch
Cyclic patch for Arbitrary Mesh Interface (AMI)
Definition: cyclicAMIPolyPatch.H:64
Foam::fvMesh::Sf
const surfaceVectorField & Sf() const
Definition: fvMeshGeometry.C:312