Loading...
Searching...
No Matches
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\*---------------------------------------------------------------------------*/
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),
54{}
55
56
57// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
58
60{
61 const labelList& coarseFra = coarseGi.faceRestrictAddressing_;
62
64 {
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
125void Foam::GAMGInterface::write(Ostream& os) const
126{
127 os << faceCells_ << token::SPACE << faceRestrictAddressing_;
128}
129
130
131// ************************************************************************* //
Abstract base class for GAMG agglomerated interfaces.
virtual label size() const
Return size.
labelList faceRestrictAddressing_
Face restrict addressing.
virtual label index() const
virtual const lduInterfacePtrsList & coarseInterfaces() const
virtual const labelUList & faceCells() const
Return faceCell addressing.
virtual tmp< scalarField > agglomerateCoeffs(const scalarField &fineCoeffs) const
Agglomerating the given fine-level coefficients and return.
const lduInterfacePtrsList & coarseInterfaces_
All interfaces.
void combine(const GAMGInterface &)
Merge the next level with this level.
tmp< Field< Type > > interfaceInternalField(const UList< Type > &internalData) const
Return the interface internal field of the given field.
labelList faceCells_
Face-cell addressing.
const label index_
My index in coarseInterfaces.
GAMGInterface(const GAMGInterface &)=delete
No copy construct.
virtual void write(Ostream &) const =0
Write to stream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
lduInterface() noexcept=default
Default construct.
A class for managing temporary objects.
Definition tmp.H:75
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition tmp.H:215
@ SPACE
Space [isspace].
Definition token.H:144
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
OBJstream os(runTime.globalPath()/outputName)
Namespace for handling debugging switches.
Definition debug.C:45
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:40
List< label > labelList
A List of labels.
Definition List.H:62
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
errorManip< error > abort(error &err)
Definition errorManip.H:139
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
UList< label > labelUList
A UList of labels.
Definition UList.H:75
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299