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-2022 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 "distributionMapBase.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 distributionMapBase* 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 distributionMapBase* 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 distributionMapBase 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  //- Map a field
148 
149  //- Map a label field
151 
152  //- Map a temporary field
153  template<class Type>
154  void operator()(Field<Type>& f, const tmp<Field<Type>>& tmapF) const;
155 
156  //- Map a temporary field
157  template<class Type>
158  tmp<Field<Type>> operator()(const tmp<Field<Type>>& tmapF) const;
159 };
160 
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 } // End namespace Foam
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #ifdef NoRepository
170 #endif
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #endif
175 
176 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
FieldMapper with weighted mapping from (optionally remote) quantities.
Class containing processor-to-processor mapping information.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
FOR_ALL_FIELD_TYPES(DEFINE_FIELD_MAPPER_OPERATOR,)
Map a field.
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 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.
void operator()(Field< Type > &f, const tmp< Field< Type >> &tmapF) const
Map a temporary field.
label constructSize() const
Constructed data size.
labelList f(nPoints)
DEFINE_FIELD_MAPPER_OPERATOR(label,)
Map a label field.
distributedWeightedFvPatchFieldMapper(const label singlePatchProc, const distributionMapBase *distMapPtr, const labelListList &addressing, const scalarListList &weights)
Construct given addressing.
A class for managing temporary objects.
Definition: PtrList.H:53
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:301
Namespace for OpenFOAM.