cyclicAMIGAMGInterfaceField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
28 #include "lduMatrix.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(cyclicAMIGAMGInterfaceField, 0);
36  (
37  GAMGInterfaceField,
38  cyclicAMIGAMGInterfaceField,
39  lduInterface
40  );
42  (
43  GAMGInterfaceField,
44  cyclicAMIGAMGInterfaceField,
45  lduInterfaceField
46  );
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
53 (
54  const GAMGInterface& GAMGCp,
55  const lduInterfaceField& fineInterface
56 )
57 :
58  GAMGInterfaceField(GAMGCp, fineInterface),
59  cyclicAMIInterface_(refCast<const cyclicAMIGAMGInterface>(GAMGCp)),
60  rank_(0)
61 {
63  refCast<const cyclicAMILduInterfaceField>(fineInterface);
64 
65  rank_ = p.rank();
66 }
67 
68 
70 (
71  const GAMGInterface& GAMGCp,
72  const int rank
73 )
74 :
75  GAMGInterfaceField(GAMGCp, rank),
76  cyclicAMIInterface_(refCast<const cyclicAMIGAMGInterface>(GAMGCp)),
77  rank_(rank)
78 {}
79 
80 
81 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
82 
84 {}
85 
86 
87 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
88 
90 (
91  scalarField& result,
92  const scalarField& psiInternal,
93  const scalarField& coeffs,
94  const direction cmpt,
96 ) const
97 {
98  const cyclicAMIGAMGInterface& thisInterface = cyclicAMIInterface_;
99  const cyclicAMIGAMGInterface& neiInterface = thisInterface.nbrPatch();
100 
101  // Get neighbouring field
102  scalarField pnf(neiInterface.interfaceInternalField(psiInternal));
103 
104  // Transform according to the transformation tensors
105  transformCoupleField(pnf, cmpt);
106 
107  // Transform and interpolate
108  scalarField pf(size(), Zero);
109  if (thisInterface.owner())
110  {
111  forAll(thisInterface.AMIs(), i)
112  {
113  const scalar r =
114  pow
115  (
116  inv(thisInterface.AMITransforms()[i]).T()(cmpt, cmpt),
117  rank()
118  );
119 
120  pf += thisInterface.AMIs()[i].interpolateToSource(r*pnf);
121  }
122  }
123  else
124  {
125  forAll(neiInterface.AMIs(), i)
126  {
127  const scalar r =
128  pow
129  (
130  neiInterface.AMITransforms()[i].T()(cmpt, cmpt),
131  rank()
132  );
133 
134  pf += neiInterface.AMIs()[i].interpolateToTarget(r*pnf);
135  }
136  }
137 
138  // Multiply the field by coefficients and add into the result
139  const labelUList& faceCells = cyclicAMIInterface_.faceCells();
140  forAll(faceCells, elemI)
141  {
142  result[faceCells[elemI]] -= coeffs[elemI]*pf[elemI];
143  }
144 }
145 
146 
147 // ************************************************************************* //
tmp< Field< Type > > interfaceInternalField(const UList< Type > &internalData) const
Return the interface internal field of the given field.
virtual const PtrList< AMIInterpolation > & AMIs() const
Return a reference to the AMI interpolators.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
GAMG agglomerated cyclic AMI interface.
commsTypes
Types of communications.
Definition: UPstream.H:64
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
uint8_t direction
Definition: direction.H:45
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.
Abstract base class for cyclic AMI coupled interfaces.
static const zero Zero
Definition: zero.H:97
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
cyclicAMIGAMGInterfaceField(const GAMGInterface &GAMGCp, const lduInterfaceField &fineInterfaceField)
Construct from GAMG interface and fine level interface field.
defineTypeNameAndDebug(combustionModel, 0)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
virtual int rank() const =0
Return rank of component for transform.
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:51
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
virtual void updateInterfaceMatrix(scalarField &result, const scalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
virtual const List< transformer > & AMITransforms() const
virtual const cyclicAMIGAMGInterface & nbrPatch() const
Return neighbour patch.
Abstract base class for GAMG agglomerated interface fields.
volScalarField & p
Namespace for OpenFOAM.
virtual bool owner() const
Does this side own the interface?