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 | Copyright (C) 2015-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::distributedWeightedFvPatchFieldMapper
26 
27 Description
28  FieldMapper with weighted mapping from (optionally remote) quantities.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #ifndef distributedWeightedFvPatchFieldMapper_H
33 #define distributedWeightedFvPatchFieldMapper_H
34 
35 #include "fvPatchFieldMapper.H"
36 #include "mapDistributeBase.H"
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 namespace Foam
41 {
42 
43 /*---------------------------------------------------------------------------*\
44  Class distributedWeightedFvPatchFieldMapper Declaration
45 \*---------------------------------------------------------------------------*/
46 
48 :
49  public fvPatchFieldMapper
50 {
51  const label singlePatchProc_;
52 
53  const mapDistributeBase* distMapPtr_;
54 
55  const labelListList& addressing_;
56 
57  const scalarListList& weights_;
58 
59  bool hasUnmapped_;
60 
61 public:
62 
63  // Constructors
64 
65  //- Construct given addressing
67  (
68  const label singlePatchProc,
69  const mapDistributeBase* distMapPtr,
71  const scalarListList& weights
72  )
73  :
74  singlePatchProc_(singlePatchProc),
75  distMapPtr_(distMapPtr),
76  addressing_(addressing),
77  weights_(weights),
78  hasUnmapped_(false)
79  {
80  forAll(addressing_, i)
81  {
82  if (addressing_[i].size() == 0)
83  {
84  hasUnmapped_ = true;
85  }
86  }
87 
88  if ((singlePatchProc_ == -1) != (distMapPtr_ != nullptr))
89  {
91  (
92  "distributedWeightedFvPatchFieldMapper::"
93  "distributedWeightedFvPatchFieldMapper(..)"
94  ) << "Supply a mapDistributeBase if and only if "
95  << "singlePatchProc is -1"
96  << " singlePatchProc_:" << singlePatchProc_
97  << " distMapPtr_:" << (distMapPtr_ != nullptr)
98  << exit(FatalError);
99  }
100  }
101 
102  //- Destructor
104  {}
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  (
137  "distributedWeightedFvPatchFieldMapper::"
138  "distributeMap()"
139  ) << "Cannot ask for distributeMap on a non-distributed"
140  << " mapper" << exit(FatalError);
141  }
142  return *distMapPtr_;
143  }
145  virtual bool hasUnmapped() const
146  {
147  return hasUnmapped_;
148  }
150  virtual const labelListList& addressing() const
151  {
152  return addressing_;
153  }
155  virtual const scalarListList& weights() const
156  {
157  return weights_;
158  }
159 
160 };
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 } // End namespace Foam
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #endif
169 
170 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
FieldMapper with weighted mapping from (optionally remote) quantities.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
virtual bool hasUnmapped() const
Are there unmapped values? I.e. do all size() elements get.
Foam::fvPatchFieldMapper.
Class containing processor-to-processor mapping information.
label constructSize() const
Constructed data size.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
Namespace for OpenFOAM.
distributedWeightedFvPatchFieldMapper(const label singlePatchProc, const mapDistributeBase *distMapPtr, const labelListList &addressing, const scalarListList &weights)
Construct given addressing.