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);
37  defineRunTimeSelectionTable(GAMGInterface, Istream);
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 
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 
126 {
127  os << faceCells_ << token::SPACE << faceRestrictAddressing_;
128 }
129 
130 
131 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::GAMGInterface::write
virtual void write(Ostream &) const =0
Write to stream.
Definition: GAMGInterface.C:125
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::GAMGInterface::faceRestrictAddressing_
labelList faceRestrictAddressing_
Face restrict addressing.
Definition: GAMGInterface.H:72
Foam::GAMGInterface::GAMGInterface
GAMGInterface(const GAMGInterface &)=delete
No copy construct.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::GAMGInterface::faceCells_
labelList faceCells_
Face-cell addressing.
Definition: GAMGInterface.H:69
GAMGInterface.H
Foam::Field< scalar >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::GAMGInterface
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:54
Foam::UPtrList< const lduInterface >
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::FatalError
error FatalError
os
OBJstream os(runTime.globalPath()/outputName)
Foam::GAMGInterface::agglomerateCoeffs
virtual tmp< scalarField > agglomerateCoeffs(const scalarField &fineCoeffs) const
Agglomerating the given fine-level coefficients and return.
Definition: GAMGInterface.C:92
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::GAMGInterface::interfaceInternalField
tmp< Field< Type > > interfaceInternalField(const UList< Type > &internalData) const
Return the interface internal field of the given field.
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::List< label >
Foam::token::SPACE
Space [isspace].
Definition: token.H:125
Foam::UList< label >
Foam::tmp::New
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56
Foam::GAMGInterface::combine
void combine(const GAMGInterface &)
Merge the next level with this level.
Definition: GAMGInterface.C:59