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-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::FieldMapper
29
30Description
31 Abstract base class to hold the Field mapping addressing and weights.
32
33\*---------------------------------------------------------------------------*/
34
35#ifndef Foam_FieldMapper_H
36#define Foam_FieldMapper_H
37
38#include "mapDistributeBase.H"
39#include "nullObject.H"
40
41// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42
43namespace Foam
44{
45
46/*---------------------------------------------------------------------------*\
47 Class FieldMapper Declaration
48\*---------------------------------------------------------------------------*/
50class FieldMapper
51{
52public:
53
54 // Constructors
55
56 //- Default construct
57 FieldMapper() = default;
58
59
60 //- Destructor
61 virtual ~FieldMapper() = default;
62
63
64 // Member Functions
65
66 //- The size of the mapper
67 virtual label size() const = 0;
68
69 //- Is it a direct (non-interpolating) mapper?
70 virtual bool direct() const = 0;
71
72 //- Does the mapper have remote contributions?
73 virtual bool distributed() const
74 {
75 return false;
76 }
77
78 //- Any unmapped values?
79 // I.e. do all size() elements get value
80 virtual bool hasUnmapped() const = 0;
81
82 //- Return the direct addressing values
83 virtual const labelUList& directAddressing() const
84 {
86 << "attempt to access null direct addressing"
87 << abort(FatalError);
88
89 return labelUList::null();
90 }
91
92 //- Return the distribution map
93 virtual const mapDistributeBase& distributeMap() const
94 {
96 << "attempt to access null distributeMap"
97 << abort(FatalError);
98
99 return NullObjectRef<mapDistributeBase>();
100 }
101
102 //- Return the interpolation addressing
103 virtual const labelListList& addressing() const
104 {
106 << "attempt to access null interpolation addressing"
107 << abort(FatalError);
108
109 return labelListList::null();
110 }
111
112 //- Return the interpolation weights
113 virtual const scalarListList& weights() const
114 {
116 << "attempt to access null interpolation weights"
117 << abort(FatalError);
118
119 return scalarListList::null();
120 }
121
122
123 // Member Operators
124
125 //- Perform mapping on the given field
126 template<class Type>
128 {
129 return tmp<Field<Type>>::New(fld, *this);
130 }
131};
132
133
134// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135
136} // End namespace Foam
137
138// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139
140#endif
141
142// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Abstract base class to hold the Field mapping addressing and weights.
Definition: FieldMapper.H:50
virtual bool direct() const =0
Is it a direct (non-interpolating) mapper?
FieldMapper()=default
Default construct.
virtual const labelUList & directAddressing() const
Return the direct addressing values.
Definition: FieldMapper.H:82
virtual ~FieldMapper()=default
Destructor.
virtual const scalarListList & weights() const
Return the interpolation weights.
Definition: FieldMapper.H:112
virtual label size() const =0
The size of the mapper.
virtual bool distributed() const
Does the mapper have remote contributions?
Definition: FieldMapper.H:72
virtual const labelListList & addressing() const
Return the interpolation addressing.
Definition: FieldMapper.H:102
virtual bool hasUnmapped() const =0
Any unmapped values?
tmp< Field< Type > > operator()(const Field< Type > &fld) const
Perform mapping on the given field.
Definition: FieldMapper.H:126
virtual const mapDistributeBase & distributeMap() const
Return the distribution map.
Definition: FieldMapper.H:92
Generic templated field type.
Definition: Field.H:82
static const List< labelList > & null()
Return a null List.
Definition: ListI.H:109
static const UList< label > & null()
Return a UList reference to a nullObject.
Definition: UListI.H:53
Class containing processor-to-processor mapping information.
A class for managing temporary objects.
Definition: tmp.H:65
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Namespace for OpenFOAM.
errorManip< error > abort(error &err)
Definition: errorManip.H:144
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
error FatalError