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 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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 
54 
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),
78  hasUnmapped_(false)
79  {
81  {
82  if (addressing_[i].size() == 0)
83  {
84  hasUnmapped_ = true;
85  }
86  }
87 
88  if ((singlePatchProc_ == -1) != (distMapPtr_ != NULL))
89  {
91  << "Supply a mapDistributeBase if and only if "
92  << "singlePatchProc is -1"
93  << " singlePatchProc_:" << singlePatchProc_
94  << " distMapPtr_:" << (distMapPtr_ != NULL)
95  << exit(FatalError);
96  }
97  }
98 
99  //- Destructor
101  {}
102 
103 
104  // Member Functions
105 
106  virtual label size() const
107  {
108  if (distributed())
109  {
110  return distributeMap().constructSize();
111  }
112  else
113  {
114  return addressing().size();
115  }
116  }
117 
118  virtual bool direct() const
119  {
120  return false;
121  }
122 
123  virtual bool distributed() const
124  {
125  return singlePatchProc_ == -1;
126  }
127 
128  virtual const mapDistributeBase& distributeMap() const
129  {
130  if (!distMapPtr_)
131  {
133  << "Cannot ask for distributeMap on a non-distributed"
134  << " mapper" << exit(FatalError);
135  }
136  return *distMapPtr_;
137  }
138 
139  virtual bool hasUnmapped() const
140  {
141  return hasUnmapped_;
142  }
143 
144  virtual const labelListList& addressing() const
145  {
146  return addressing_;
147  }
148 
149  virtual const scalarListList& weights() const
150  {
151  return weights_;
152  }
153 
154 };
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace Foam
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #endif
163 
164 // ************************************************************************* //
Foam::distributedWeightedFvPatchFieldMapper::weights_
const scalarListList & weights_
Definition: distributedWeightedFvPatchFieldMapper.H:56
Foam::distributedWeightedFvPatchFieldMapper::addressing
virtual const labelListList & addressing() const
Definition: distributedWeightedFvPatchFieldMapper.H:143
mapDistributeBase.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::distributedWeightedFvPatchFieldMapper::hasUnmapped
virtual bool hasUnmapped() const
Are there unmapped values? I.e. do all size() elements get.
Definition: distributedWeightedFvPatchFieldMapper.H:138
Foam::distributedWeightedFvPatchFieldMapper::hasUnmapped_
bool hasUnmapped_
Definition: distributedWeightedFvPatchFieldMapper.H:58
fvPatchFieldMapper.H
Foam::distributedWeightedFvPatchFieldMapper::singlePatchProc_
const label singlePatchProc_
Definition: distributedWeightedFvPatchFieldMapper.H:50
Foam::distributedWeightedFvPatchFieldMapper::size
virtual label size() const
Definition: distributedWeightedFvPatchFieldMapper.H:105
Foam::distributedWeightedFvPatchFieldMapper::distributeMap
virtual const mapDistributeBase & distributeMap() const
Definition: distributedWeightedFvPatchFieldMapper.H:127
Foam::label
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
Foam::distributedWeightedFvPatchFieldMapper::distMapPtr_
const mapDistributeBase * distMapPtr_
Definition: distributedWeightedFvPatchFieldMapper.H:52
Foam::distributedWeightedFvPatchFieldMapper::distributed
virtual bool distributed() const
Definition: distributedWeightedFvPatchFieldMapper.H:122
Foam::distributedWeightedFvPatchFieldMapper::distributedWeightedFvPatchFieldMapper
distributedWeightedFvPatchFieldMapper(const label singlePatchProc, const mapDistributeBase *distMapPtr, const labelListList &addressing, const scalarListList &weights)
Construct given addressing.
Definition: distributedWeightedFvPatchFieldMapper.H:66
Foam::distributedWeightedFvPatchFieldMapper::direct
virtual bool direct() const
Definition: distributedWeightedFvPatchFieldMapper.H:117
Foam::FatalError
error FatalError
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::mapDistributeBase::constructSize
label constructSize() const
Constructed data size.
Definition: mapDistributeBase.H:244
Foam::distributedWeightedFvPatchFieldMapper::weights
virtual const scalarListList & weights() const
Definition: distributedWeightedFvPatchFieldMapper.H:148
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::List
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
Foam::mapDistributeBase
Class containing processor-to-processor mapping information.
Definition: mapDistributeBase.H:91
Foam::distributedWeightedFvPatchFieldMapper::addressing_
const labelListList & addressing_
Definition: distributedWeightedFvPatchFieldMapper.H:54
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::distributedWeightedFvPatchFieldMapper::~distributedWeightedFvPatchFieldMapper
virtual ~distributedWeightedFvPatchFieldMapper()
Destructor.
Definition: distributedWeightedFvPatchFieldMapper.H:99
Foam::distributedWeightedFvPatchFieldMapper
FieldMapper with weighted mapping from (optionally remote) quantities.
Definition: distributedWeightedFvPatchFieldMapper.H:46