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-------------------------------------------------------------------------------
11License
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
33namespace Foam
34{
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
63 forAll(faceRestrictAddressing_, ffi)
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,
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// ************************************************************************* //
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:57
labelList faceRestrictAddressing_
Face restrict addressing.
Definition: GAMGInterface.H:72
virtual tmp< scalarField > agglomerateCoeffs(const scalarField &fineCoeffs) const
Agglomerating the given fine-level coefficients and return.
Definition: GAMGInterface.C:92
tmp< Field< Type > > interfaceInternalField(const UList< Type > &internalData) const
Return the interface internal field of the given field.
labelList faceCells_
Face-cell addressing.
Definition: GAMGInterface.H:69
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:59
virtual bool write()
Write the output fields.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
Definition: lduInterface.H:58
A class for managing temporary objects.
Definition: tmp.H:65
@ SPACE
Space [isspace].
Definition: token.H:125
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
errorManip< error > abort(error &err)
Definition: errorManip.H:144
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
error FatalError
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333