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 | Copyright (C) 2011-2013 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 
40 Foam::GAMGInterface::GAMGInterface
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();
85 
86  if (fineCoeffs.size() != faceRestrictAddressing_.size())
87  {
89  (
90  "GAMGInterface::agglomerateCoeffs(const scalarField&) const"
91  ) << "Size of coefficients " << fineCoeffs.size()
92  << " does not correspond to the size of the restriction "
93  << faceRestrictAddressing_.size()
94  << abort(FatalError);
95  }
96  if (debug && max(faceRestrictAddressing_) > size())
97  {
99  (
100  "GAMGInterface::agglomerateCoeffs(const scalarField&) const"
101  ) << "Face restrict addressing addresses outside of coarse interface"
102  << " size. Max addressing:" << max(faceRestrictAddressing_)
103  << " coarse size:" << size()
104  << abort(FatalError);
105  }
106 
107  forAll(faceRestrictAddressing_, ffi)
108  {
109  coarseCoeffs[faceRestrictAddressing_[ffi]] += fineCoeffs[ffi];
110  }
111 
112  return tcoarseCoeffs;
113 }
114 
115 
117 {
118  os << faceCells_ << token::SPACE << faceRestrictAddressing_;
119 }
120 
121 
122 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
labelList faceCells_
Face-cell addressing.
Definition: GAMGInterface.H:67
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define forAll(list, i)
Definition: UList.H:421
void combine(const GAMGInterface &)
Merge the next level with this level.
Definition: GAMGInterface.C:56
errorManip< error > abort(error &err)
Definition: errorManip.H:131
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
virtual void write(Ostream &) const =0
Write to stream.
error FatalError
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
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:51
labelList faceRestrictAddressing_
Face restrict addressing.
Definition: GAMGInterface.H:70
virtual tmp< scalarField > agglomerateCoeffs(const scalarField &fineCoeffs) const
Agglomerating the given fine-level coefficients and return.
Definition: GAMGInterface.C:79
A class for managing temporary objects.
Definition: PtrList.H:118
tmp< Field< Type > > interfaceInternalField(const UList< Type > &internalData) const
Return the interface internal field of the given field.
defineTypeNameAndDebug(combustionModel, 0)