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 -------------------------------------------------------------------------------
11 License
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 Class
28  Foam::distributedWeightedFvPatchFieldMapper
29 
30 Description
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 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class distributedWeightedFvPatchFieldMapper Declaration
48 \*---------------------------------------------------------------------------*/
49 
51 :
52  public fvPatchFieldMapper
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 
64 public:
65 
66  // Constructors
67 
68  //- Construct given addressing
70  (
71  const label singlePatchProc,
72  const mapDistributeBase* distMapPtr,
74  const scalarListList& weights
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 
107  // Member Functions
108 
109  virtual label size() const
110  {
111  if (distributed())
112  {
113  return distributeMap().constructSize();
114  }
115  else
116  {
117  return addressing().size();
118  }
119  }
120 
121  virtual bool direct() const
122  {
123  return false;
124  }
125 
126  virtual bool distributed() const
127  {
128  return singlePatchProc_ == -1;
129  }
130 
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  }
141 
142  virtual bool hasUnmapped() const
143  {
144  return hasUnmapped_;
145  }
146 
147  virtual const labelListList& addressing() const
148  {
149  return addressing_;
150  }
151 
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 // ************************************************************************* //
virtual bool direct() const
Is it a direct (non-interpolating) mapper?
virtual const scalarListList & weights() const
Return the interpolation weights.
virtual bool distributed() const
Does the mapper have remote contributions?
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
FieldMapper with weighted mapping from (optionally remote) quantities.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
label constructSize() const noexcept
Constructed data size.
virtual label size() const
The size of the mapper.
A FieldMapper for finite-volume patch fields.
virtual const mapDistributeBase & distributeMap() const
Return the distribution map.
virtual ~distributedWeightedFvPatchFieldMapper()=default
Destructor.
Class containing processor-to-processor mapping information.
virtual const labelListList & addressing() const
Return the interpolation addressing.
Namespace for OpenFOAM.
distributedWeightedFvPatchFieldMapper(const label singlePatchProc, const mapDistributeBase *distMapPtr, const labelListList &addressing, const scalarListList &weights)
Construct given addressing.