distributedWeightedFvPatchFieldMapper.H
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) 2015-2016 OpenFOAM Foundation
9 Copyright (C) 2015-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
27Class
28 Foam::distributedWeightedFvPatchFieldMapper
29
30Description
31 FieldMapper with weighted mapping from (optionally remote) quantities.
32
33\*---------------------------------------------------------------------------*/
34
35#ifndef distributedWeightedFvPatchFieldMapper_H
36#define distributedWeightedFvPatchFieldMapper_H
37
38#include "fvPatchFieldMapper.H"
39#include "mapDistributeBase.H"
40
41// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42
43namespace Foam
44{
45
46/*---------------------------------------------------------------------------*\
47 Class distributedWeightedFvPatchFieldMapper Declaration
48\*---------------------------------------------------------------------------*/
51:
53{
54 const label singlePatchProc_;
55
56 const mapDistributeBase* distMapPtr_;
57
58 const labelListList& addressing_;
59
60 const scalarListList& weights_;
61
62 bool hasUnmapped_;
63
64public:
65
66 // Constructors
67
68 //- Construct given addressing
70 (
71 const label singlePatchProc,
72 const mapDistributeBase* distMapPtr,
75 )
76 :
77 singlePatchProc_(singlePatchProc),
78 distMapPtr_(distMapPtr),
79 addressing_(addressing),
80 weights_(weights),
81 hasUnmapped_(false)
82 {
83 for (const labelList& addr : addressing)
84 {
85 if (addr.empty())
86 {
87 hasUnmapped_ = true;
88 break;
89 }
90 }
91
92 if ((singlePatchProc_ == -1) != (distMapPtr_ != nullptr))
93 {
95 << "Supply a mapDistributeBase if and only if "
96 << "singlePatchProc is -1"
97 << " singlePatchProc_:" << singlePatchProc_
98 << " distMapPtr_:" << (distMapPtr_ != nullptr)
99 << exit(FatalError);
100 }
101 }
102
103 //- Destructor
104 virtual ~distributedWeightedFvPatchFieldMapper() = default;
105
106
107 // Member Functions
109 virtual label size() const
110 {
111 if (distributed())
112 {
113 return distributeMap().constructSize();
114 }
115 else
116 {
117 return addressing().size();
118 }
119 }
121 virtual bool direct() const
122 {
123 return false;
124 }
126 virtual bool distributed() const
127 {
128 return singlePatchProc_ == -1;
129 }
131 virtual const mapDistributeBase& distributeMap() const
132 {
133 if (!distMapPtr_)
134 {
136 << "Cannot ask for distributeMap on a non-distributed"
137 << " mapper" << exit(FatalError);
138 }
139 return *distMapPtr_;
140 }
142 virtual bool hasUnmapped() const
143 {
144 return hasUnmapped_;
145 }
147 virtual const labelListList& addressing() const
148 {
149 return addressing_;
150 }
152 virtual const scalarListList& weights() const
153 {
154 return weights_;
155 }
156
157};
158
159// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160
161} // End namespace Foam
162
163// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164
165#endif
166
167// ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
FieldMapper with weighted mapping from (optionally remote) quantities.
distributedWeightedFvPatchFieldMapper(const label singlePatchProc, const mapDistributeBase *distMapPtr, const labelListList &addressing, const scalarListList &weights)
Construct given addressing.
virtual ~distributedWeightedFvPatchFieldMapper()=default
Destructor.
virtual const scalarListList & weights() const
Return the interpolation weights.
virtual bool distributed() const
Does the mapper have remote contributions?
virtual const labelListList & addressing() const
Return the interpolation addressing.
virtual bool direct() const
Is it a direct (non-interpolating) mapper?
virtual const mapDistributeBase & distributeMap() const
Return the distribution map.
A FieldMapper for finite-volume patch fields.
Class containing processor-to-processor mapping information.
label constructSize() const noexcept
Constructed data size.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Namespace for OpenFOAM.
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130