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 
106 
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 // ************************************************************************* //
Foam::distributedWeightedFvPatchFieldMapper::~distributedWeightedFvPatchFieldMapper
virtual ~distributedWeightedFvPatchFieldMapper()=default
Destructor.
Foam::distributedWeightedFvPatchFieldMapper::addressing
virtual const labelListList & addressing() const
Definition: distributedWeightedFvPatchFieldMapper.H:146
mapDistributeBase.H
Foam::distributedWeightedFvPatchFieldMapper::hasUnmapped
virtual bool hasUnmapped() const
Are there unmapped values? I.e. do all size() elements get.
Definition: distributedWeightedFvPatchFieldMapper.H:141
fvPatchFieldMapper.H
Foam::distributedWeightedFvPatchFieldMapper::size
virtual label size() const
Definition: distributedWeightedFvPatchFieldMapper.H:108
Foam::distributedWeightedFvPatchFieldMapper::distributeMap
virtual const mapDistributeBase & distributeMap() const
Definition: distributedWeightedFvPatchFieldMapper.H:130
Foam::distributedWeightedFvPatchFieldMapper::distributed
virtual bool distributed() const
Definition: distributedWeightedFvPatchFieldMapper.H:125
Foam::distributedWeightedFvPatchFieldMapper::distributedWeightedFvPatchFieldMapper
distributedWeightedFvPatchFieldMapper(const label singlePatchProc, const mapDistributeBase *distMapPtr, const labelListList &addressing, const scalarListList &weights)
Construct given addressing.
Definition: distributedWeightedFvPatchFieldMapper.H:69
Foam::distributedWeightedFvPatchFieldMapper::direct
virtual bool direct() const
Definition: distributedWeightedFvPatchFieldMapper.H:120
Foam::FatalError
error FatalError
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::mapDistributeBase::constructSize
label constructSize() const
Constructed data size.
Definition: mapDistributeBase.H:277
Foam::distributedWeightedFvPatchFieldMapper::weights
virtual const scalarListList & weights() const
Definition: distributedWeightedFvPatchFieldMapper.H:151
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::mapDistributeBase
Class containing processor-to-processor mapping information.
Definition: mapDistributeBase.H:103
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::distributedWeightedFvPatchFieldMapper
FieldMapper with weighted mapping from (optionally remote) quantities.
Definition: distributedWeightedFvPatchFieldMapper.H:49