FieldMapper.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) 2011-2017 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::FieldMapper
29 
30 Description
31  Abstract base class to hold the Field mapping addressing and weights.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef FieldMapper_H
36 #define FieldMapper_H
37 
38 #include "mapDistributeBase.H"
39 #include "nullObject.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class FieldMapper Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class FieldMapper
51 {
52 
53 public:
54 
55  // Constructors
56 
57  //- Null constructor
58  FieldMapper()
59  {}
60 
61 
62  //- Destructor
63  virtual ~FieldMapper() = default;
64 
65 
66  // Member Functions
67 
68  virtual label size() const = 0;
69 
70  virtual bool direct() const = 0;
71 
72  virtual bool distributed() const
73  {
74  return false;
75  }
76 
77  virtual const mapDistributeBase& distributeMap() const
78  {
80  << "attempt to access null distributeMap"
81  << abort(FatalError);
82 
83  return NullObjectRef<mapDistributeBase>();
84  }
85 
86  //- Are there unmapped values? I.e. do all size() elements get
87  // get value
88  virtual bool hasUnmapped() const = 0;
89 
90  virtual const labelUList& directAddressing() const
91  {
93  << "attempt to access null direct addressing"
94  << abort(FatalError);
95 
96  return labelUList::null();
97  }
98 
99  virtual const labelListList& addressing() const
100  {
102  << "attempt to access null interpolation addressing"
103  << abort(FatalError);
104 
105  return labelListList::null();
106  }
107 
108  virtual const scalarListList& weights() const
109  {
111  << "attempt to access null interpolation weights"
112  << abort(FatalError);
113 
114  return scalarListList::null();
115  }
116 
117 
118  // Member Operators
119 
120  template<class Type>
121  tmp<Field<Type>> operator()(const Field<Type>& f) const
122  {
123  return tmp<Field<Type>>::New(f, *this);
124  }
125 };
126 
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 } // End namespace Foam
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 
134 #endif
135 
136 // ************************************************************************* //
Foam::FieldMapper::~FieldMapper
virtual ~FieldMapper()=default
Destructor.
Foam::List< labelList >::null
static const List< labelList > & null()
Return a null List.
Definition: ListI.H:109
mapDistributeBase.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::FieldMapper::size
virtual label size() const =0
Foam::FieldMapper::weights
virtual const scalarListList & weights() const
Definition: FieldMapper.H:107
Foam::FieldMapper
Abstract base class to hold the Field mapping addressing and weights.
Definition: FieldMapper.H:49
Foam::FieldMapper::direct
virtual bool direct() const =0
Foam::FieldMapper::hasUnmapped
virtual bool hasUnmapped() const =0
Are there unmapped values? I.e. do all size() elements get.
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::FatalError
error FatalError
Foam::FieldMapper::directAddressing
virtual const labelUList & directAddressing() const
Definition: FieldMapper.H:89
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::FieldMapper::addressing
virtual const labelListList & addressing() const
Definition: FieldMapper.H:98
f
labelList f(nPoints)
Foam::List< labelList >
Foam::UList< label >
Foam::FieldMapper::operator()
tmp< Field< Type > > operator()(const Field< Type > &f) const
Definition: FieldMapper.H:120
Foam::mapDistributeBase
Class containing processor-to-processor mapping information.
Definition: mapDistributeBase.H:103
nullObject.H
Foam::UList::null
static const UList< T > & null()
Return a UList reference to a nullObject.
Definition: UListI.H:53
Foam::FieldMapper::distributeMap
virtual const mapDistributeBase & distributeMap() const
Definition: FieldMapper.H:76
Foam::FieldMapper::distributed
virtual bool distributed() const
Definition: FieldMapper.H:71
Foam::FieldMapper::FieldMapper
FieldMapper()
Null constructor.
Definition: FieldMapper.H:57