GAMGInterface.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-2016 OpenFOAM Foundation
9  Copyright (C) 2019 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 
29 #include "GAMGInterface.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(GAMGInterface, 0);
36  defineRunTimeSelectionTable(GAMGInterface, lduInterface);
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const label index,
46  const lduInterfacePtrsList& coarseInterfaces,
47  Istream& is
48 )
49 :
50  index_(index),
51  coarseInterfaces_(coarseInterfaces),
52  faceCells_(is),
53  faceRestrictAddressing_(is)
54 {}
55 
56 
57 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
58 
59 void Foam::GAMGInterface::combine(const GAMGInterface& coarseGi)
60 {
61  const labelList& coarseFra = coarseGi.faceRestrictAddressing_;
62 
64  {
65  faceRestrictAddressing_[ffi] = coarseFra[faceRestrictAddressing_[ffi]];
66  }
67 
68  faceCells_ = coarseGi.faceCells_;
69 }
70 
71 
73 (
74  const labelUList& internalData
75 ) const
76 {
77  return interfaceInternalField<label>(internalData);
78 }
79 
80 
82 (
83  const labelUList& internalData,
84  const labelUList& faceCells
85 ) const
86 {
87  return interfaceInternalField<label>(internalData, faceCells);
88 }
89 
90 
92 (
93  const scalarField& fineCoeffs
94 ) const
95 {
96  auto tcoarseCoeffs = tmp<scalarField>::New(size(), Zero);
97  auto& coarseCoeffs = tcoarseCoeffs.ref();
98 
99  if (fineCoeffs.size() != faceRestrictAddressing_.size())
100  {
102  << "Size of coefficients " << fineCoeffs.size()
103  << " does not correspond to the size of the restriction "
104  << faceRestrictAddressing_.size()
105  << abort(FatalError);
106  }
107  if (debug && max(faceRestrictAddressing_) > size())
108  {
110  << "Face restrict addressing addresses outside of coarse interface"
111  << " size. Max addressing:" << max(faceRestrictAddressing_)
112  << " coarse size:" << size()
113  << abort(FatalError);
114  }
115 
116  forAll(faceRestrictAddressing_, ffi)
117  {
118  coarseCoeffs[faceRestrictAddressing_[ffi]] += fineCoeffs[ffi];
119  }
120 
121  return tcoarseCoeffs;
122 }
123 
124 
125 void Foam::GAMGInterface::write(Ostream& os) const
126 {
127  os << faceCells_ << token::SPACE << faceRestrictAddressing_;
128 }
129 
130 
131 // ************************************************************************* //
tmp< Field< Type > > interfaceInternalField(const UList< Type > &internalData) const
Return the interface internal field of the given field.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
labelList faceRestrictAddressing_
Face restrict addressing.
Definition: GAMGInterface.H:76
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:52
UList< label > labelUList
A UList of labels.
Definition: UList.H:78
GAMGInterface(const GAMGInterface &)=delete
No copy construct.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
Space [isspace].
Definition: token.H:131
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition: tmp.H:206
errorManip< error > abort(error &err)
Definition: errorManip.H:139
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
virtual tmp< scalarField > agglomerateCoeffs(const scalarField &fineCoeffs) const
Agglomerating the given fine-level coefficients and return.
Definition: GAMGInterface.C:85
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:50
void combine(const GAMGInterface &)
Merge the next level with this level.
Definition: GAMGInterface.C:52
virtual void write(Ostream &) const =0
Write to stream.
labelList faceCells_
Face-cell addressing.
Definition: GAMGInterface.H:71
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127