cyclicGAMGInterfaceField.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) 2011-2013 OpenFOAM Foundation
9  Copyright (C) 2019,2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
31 #include "lduMatrix.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(cyclicGAMGInterfaceField, 0);
39  (
40  GAMGInterfaceField,
41  cyclicGAMGInterfaceField,
42  lduInterface
43  );
45  (
46  GAMGInterfaceField,
47  cyclicGAMGInterfaceField,
48  lduInterfaceField
49  );
51  (
52  GAMGInterfaceField,
53  cyclicGAMGInterfaceField,
54  Istream
55  );
56 
57  // Add under name cyclicSlip
59  (
60  GAMGInterfaceField,
61  cyclicGAMGInterfaceField,
62  lduInterface,
63  cyclicSlip
64  );
66  (
67  GAMGInterfaceField,
68  cyclicGAMGInterfaceField,
69  lduInterfaceField,
70  cyclicSlip
71  );
73  (
74  GAMGInterfaceField,
75  cyclicGAMGInterfaceField,
76  Istream,
77  cyclicSlip
78  );
79 }
80 
81 
82 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
83 
84 Foam::cyclicGAMGInterfaceField::cyclicGAMGInterfaceField
85 (
86  const GAMGInterface& GAMGCp,
87  const lduInterfaceField& fineInterface
88 )
89 :
90  GAMGInterfaceField(GAMGCp, fineInterface),
91  cyclicInterface_(refCast<const cyclicGAMGInterface>(GAMGCp)),
92  doTransform_(false),
93  rank_(0)
94 {
95  const cyclicLduInterfaceField& p =
96  refCast<const cyclicLduInterfaceField>(fineInterface);
97 
98  doTransform_ = p.doTransform();
99  rank_ = p.rank();
100 }
101 
102 
103 Foam::cyclicGAMGInterfaceField::cyclicGAMGInterfaceField
104 (
105  const GAMGInterface& GAMGCp,
106  const bool doTransform,
107  const int rank
108 )
109 :
110  GAMGInterfaceField(GAMGCp, doTransform, rank),
111  cyclicInterface_(refCast<const cyclicGAMGInterface>(GAMGCp)),
112  doTransform_(doTransform),
113  rank_(rank)
114 {}
115 
116 
117 Foam::cyclicGAMGInterfaceField::cyclicGAMGInterfaceField
118 (
119  const GAMGInterface& GAMGCp,
120  Istream& is
121 )
122 :
123  GAMGInterfaceField(GAMGCp, is),
124  cyclicInterface_(refCast<const cyclicGAMGInterface>(GAMGCp)),
125  doTransform_(readBool(is)),
126  rank_(readLabel(is))
127 {}
128 
129 
130 Foam::cyclicGAMGInterfaceField::cyclicGAMGInterfaceField
131 (
132  const GAMGInterface& GAMGCp,
133  const lduInterfaceField& local,
134  const UPtrList<lduInterfaceField>& other
135 )
136 :
137  GAMGInterfaceField(GAMGCp, local),
138  cyclicInterface_(refCast<const cyclicGAMGInterface>(GAMGCp)),
139  doTransform_(false),
140  rank_(0)
141 {
142  const auto& p = refCast<const cyclicLduInterfaceField>(local);
143 
144  doTransform_ = p.doTransform();
145  rank_ = p.rank();
146 }
147 
148 
149 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
150 
152 (
153  solveScalarField& result,
154  const bool add,
155  const lduAddressing& lduAddr,
156  const label patchId,
157  const solveScalarField& psiInternal,
158  const scalarField& coeffs,
159  const direction cmpt,
160  const Pstream::commsTypes
161 ) const
162 {
163  // Get neighbouring field
164 
165  const labelList& nbrFaceCells =
166  lduAddr.patchAddr
167  (
168  cyclicInterface_.neighbPatchID()
169  );
170 
171  solveScalarField pnf(psiInternal, nbrFaceCells);
172 
173  transformCoupleField(pnf, cmpt);
175  const labelList& faceCells = lduAddr.patchAddr(patchId);
176 
177  this->addToInternalField(result, !add, faceCells, coeffs, pnf);
178 }
179 
180 
182 {
183  //GAMGInterfaceField::write(os);
184  os << token::SPACE << doTransform()
185  << token::SPACE << rank();
186 }
187 
188 
189 // ************************************************************************* //
label patchId(-1)
uint8_t direction
Definition: direction.H:46
commsTypes
Communications types.
Definition: UPstream.H:72
virtual void write(Ostream &) const
Write to stream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Type & refCast(U &obj)
A dynamic_cast (for references). Generates a FatalError on failed casts and uses the virtual type() m...
Definition: typeInfo.H:159
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition: label.H:63
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:52
An abstract base class for implicitly-coupled interface fields e.g. processor and cyclic patch fields...
Macros for easy insertion into run-time selection tables.
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
Space [isspace].
Definition: token.H:131
virtual const labelUList & patchAddr(const label patchNo) const =0
Return patch to internal addressing given patch number.
bool local
Definition: EEqn.H:20
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:50
::Foam::direction rank(const expressions::valueTypeCode) noexcept
The vector-space rank associated with given valueTypeCode.
Definition: exprTraits.C:70
Abstract base class for GAMG agglomerated interface fields.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
volScalarField & p
Abstract base class for cyclic coupled interfaces.
bool readBool(Istream &is)
Read bool from stream using Foam::Switch(Istream&)
Definition: bool.C:62
Namespace for OpenFOAM.
GAMG agglomerated cyclic interface.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)