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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "GAMGInterface.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(GAMGInterface, 0);
35  defineRunTimeSelectionTable(GAMGInterface, lduInterface);
36  defineRunTimeSelectionTable(GAMGInterface, Istream);
37 }
38 
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
42 Foam::GAMGInterface::GAMGInterface
43 (
44  const label index,
45  const lduInterfacePtrsList& coarseInterfaces,
46  Istream& is
47 )
48 :
49  index_(index),
50  coarseInterfaces_(coarseInterfaces),
51  faceCells_(is),
52  faceRestrictAddressing_(is)
53 {}
54 
55 
56 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
57 
59 {
60  const labelList& coarseFra = coarseGi.faceRestrictAddressing_;
61 
63  {
64  faceRestrictAddressing_[ffi] = coarseFra[faceRestrictAddressing_[ffi]];
65  }
66 
67  faceCells_ = coarseGi.faceCells_;
68 }
69 
70 
72 (
73  const labelUList& internalData
74 ) const
75 {
76  return interfaceInternalField<label>(internalData);
77 }
78 
79 
81 (
82  const scalarField& fineCoeffs
83 ) const
84 {
85  tmp<scalarField> tcoarseCoeffs(new scalarField(size(), Zero));
86  scalarField& coarseCoeffs = tcoarseCoeffs.ref();
87 
88  if (fineCoeffs.size() != faceRestrictAddressing_.size())
89  {
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  << "Face restrict addressing addresses outside of coarse interface"
100  << " size. Max addressing:" << max(faceRestrictAddressing_)
101  << " coarse size:" << size()
102  << abort(FatalError);
103  }
104 
105  forAll(faceRestrictAddressing_, ffi)
106  {
107  coarseCoeffs[faceRestrictAddressing_[ffi]] += fineCoeffs[ffi];
108  }
109 
110  return tcoarseCoeffs;
111 }
112 
113 
115 {
116  os << faceCells_ << token::SPACE << faceRestrictAddressing_;
117 }
118 
119 
120 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::GAMGInterface::write
virtual void write(Ostream &) const =0
Write to stream.
Definition: GAMGInterface.C:114
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
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::tmp::ref
T & ref() const
Definition: tmpI.H:228
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:53
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
Foam::GAMGInterface::agglomerateCoeffs
virtual tmp< scalarField > agglomerateCoeffs(const scalarField &fineCoeffs) const
Agglomerating the given fine-level coefficients and return.
Definition: GAMGInterface.C:81
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:381
Foam::List< label >
Foam::token::SPACE
Space [isspace].
Definition: token.H:117
Foam::UList< label >
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::GAMGInterface::combine
void combine(const GAMGInterface &)
Merge the next level with this level.
Definition: GAMGInterface.C:58