GAMGInterface.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-2018 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 
26 #include "GAMGInterface.H"
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32  defineTypeNameAndDebug(GAMGInterface, 0);
33  defineRunTimeSelectionTable(GAMGInterface, lduInterface);
34  defineRunTimeSelectionTable(GAMGInterface, Istream);
35 }
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 (
42  const label index,
43  const lduInterfacePtrsList& coarseInterfaces,
44  Istream& is
45 )
46 :
47  index_(index),
48  coarseInterfaces_(coarseInterfaces),
49  faceCells_(is),
50  faceRestrictAddressing_(is)
51 {}
52 
53 
54 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
55 
57 {
58  const labelList& coarseFra = coarseGi.faceRestrictAddressing_;
59 
60  forAll(faceRestrictAddressing_, ffi)
61  {
62  faceRestrictAddressing_[ffi] = coarseFra[faceRestrictAddressing_[ffi]];
63  }
64 
65  faceCells_ = coarseGi.faceCells_;
66 }
67 
68 
70 (
71  const labelUList& internalData
72 ) const
73 {
74  return interfaceInternalField<label>(internalData);
75 }
76 
77 
79 (
80  const scalarField& fineCoeffs
81 ) const
82 {
83  tmp<scalarField> tcoarseCoeffs(new scalarField(size(), 0.0));
84  scalarField& coarseCoeffs = tcoarseCoeffs.ref();
85 
86  if (fineCoeffs.size() != faceRestrictAddressing_.size())
87  {
89  << "Size of coefficients " << fineCoeffs.size()
90  << " does not correspond to the size of the restriction "
91  << faceRestrictAddressing_.size()
92  << abort(FatalError);
93  }
94  if (debug && max(faceRestrictAddressing_) > size())
95  {
97  << "Face restrict addressing addresses outside of coarse interface"
98  << " size. Max addressing:" << max(faceRestrictAddressing_)
99  << " coarse size:" << size()
100  << abort(FatalError);
101  }
102 
103  forAll(faceRestrictAddressing_, ffi)
104  {
105  coarseCoeffs[faceRestrictAddressing_[ffi]] += fineCoeffs[ffi];
106  }
107 
108  return tcoarseCoeffs;
109 }
110 
111 
113 {
114  os << faceCells_ << token::SPACE << faceRestrictAddressing_;
115 }
116 
117 
118 // ************************************************************************* //
tmp< Field< Type > > interfaceInternalField(const UList< Type > &internalData) const
Return the interface internal field of the given field.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
error FatalError
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
labelList faceRestrictAddressing_
Face restrict addressing.
Definition: GAMGInterface.H:70
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
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
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
virtual tmp< scalarField > agglomerateCoeffs(const scalarField &fineCoeffs) const
Agglomerating the given fine-level coefficients and return.
Definition: GAMGInterface.C:79
GAMGInterface(const label index, const lduInterfacePtrsList &coarseInterfaces)
Construct from interfaces, restrict addressing set later on.
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:51
void combine(const GAMGInterface &)
Merge the next level with this level.
Definition: GAMGInterface.C:56
virtual void write(Ostream &) const =0
Write to stream.
labelList faceCells_
Face-cell addressing.
Definition: GAMGInterface.H:67
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.