distributedWeightedFvPatchFieldMapper.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2015-2020 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  // Private Data
52 
53  const label singlePatchProc_;
54 
55  const mapDistributeBase* distMapPtr_;
56 
57  const labelListList& addressing_;
58 
59  const scalarListList& weights_;
60 
61  bool hasUnmapped_;
62 
63 
64  // Private Member Functions
65 
66  label size() const
67  {
68  if (singlePatchProc_ == -1)
69  {
70  return distMapPtr_->constructSize();
71  }
72  else
73  {
74  return addressing().size();
75  }
76  }
77 
78  template<class Type>
79  void map(Field<Type>& f, const Field<Type>& mapF) const;
80 
81  template<class Type>
82  tmp<Field<Type>> map(const Field<Type>& f) const;
83 
84 
85 public:
86 
87  // Constructors
88 
89  //- Construct given addressing
91  (
92  const label singlePatchProc,
93  const mapDistributeBase* distMapPtr,
95  const scalarListList& weights
96  )
97  :
98  singlePatchProc_(singlePatchProc),
99  distMapPtr_(distMapPtr),
100  addressing_(addressing),
101  weights_(weights),
102  hasUnmapped_(false)
103  {
104  forAll(addressing_, i)
105  {
106  if (addressing_[i].size() == 0)
107  {
108  hasUnmapped_ = true;
109  }
110  }
111 
112  if ((singlePatchProc_ == -1) != (distMapPtr_ != nullptr))
113  {
115  (
116  "distributedWeightedFvPatchFieldMapper::"
117  "distributedWeightedFvPatchFieldMapper(..)"
118  ) << "Supply a mapDistributeBase if and only if "
119  << "singlePatchProc is -1"
120  << " singlePatchProc_:" << singlePatchProc_
121  << " distMapPtr_:" << (distMapPtr_ != nullptr)
122  << exit(FatalError);
123  }
124  }
125 
126 
127  //- Destructor
129  {}
130 
131 
132  // Member Functions
134  virtual bool hasUnmapped() const
135  {
136  return hasUnmapped_;
137  }
138 
139  virtual const labelListList& addressing() const;
140 
141  virtual const scalarListList& weights() const;
142 
143 
144  // Member Operators
145 
146  virtual void operator()
147  (
148  Field<scalar>& f,
149  const Field<scalar>& mapF
150  ) const;
151 
152  virtual void operator()
153  (
154  Field<vector>& f,
155  const Field<vector>& mapF
156  ) const;
157 
158  virtual void operator()
159  (
161  const Field<sphericalTensor>& mapF
162  ) const;
163 
164  virtual void operator()
165  (
167  const Field<symmTensor>& mapF
168  ) const;
169 
170  virtual void operator()
171  (
172  Field<tensor>& f,
173  const Field<tensor>& mapF
174  ) const;
175 
176  template<class Type>
177  void operator()(Field<Type>& f, const tmp<Field<Type>>& tmapF) const;
178 
179 
180  virtual tmp<Field<scalar>> operator()
181  (
182  const Field<scalar>& mapF
183  ) const;
184 
185  virtual tmp<Field<vector>> operator()
186  (
187  const Field<vector>& mapF
188  ) const;
189 
190  virtual tmp<Field<sphericalTensor>> operator()
191  (
192  const Field<sphericalTensor>& mapF
193  ) const;
194 
195  virtual tmp<Field<symmTensor>> operator()
196  (
197  const Field<symmTensor>& mapF
198  ) const;
199 
200  virtual tmp<Field<tensor>> operator()
201  (
202  const Field<tensor>& mapF
203  ) const;
204 
205  template<class Type>
206  tmp<Field<Type>> operator()(const tmp<Field<Type>>& tmapF) const;
207 };
208 
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 } // End namespace Foam
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #ifdef NoRepository
218 #endif
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 #endif
223 
224 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
virtual void operator()(Field< scalar > &f, const Field< scalar > &mapF) const
virtual bool hasUnmapped() const
Are there unmapped values? I.e. do all size() elements get.
Pre-declare SubField and related Field type.
Definition: Field.H:56
Foam::fvPatchFieldMapper.
Class containing processor-to-processor mapping information.
labelList f(nPoints)
label constructSize() const
Constructed data size.
A class for managing temporary objects.
Definition: PtrList.H:53
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:318
Namespace for OpenFOAM.
distributedWeightedFvPatchFieldMapper(const label singlePatchProc, const mapDistributeBase *distMapPtr, const labelListList &addressing, const scalarListList &weights)
Construct given addressing.