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 -------------------------------------------------------------------------------
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 Foam_FieldMapper_H
36 #define Foam_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 public:
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 // ************************************************************************* //
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
virtual ~FieldMapper()=default
Destructor.
FieldMapper()=default
Default construct.
virtual const labelListList & addressing() const
Return the interpolation addressing.
Definition: FieldMapper.H:115
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
virtual bool direct() const =0
Is it a direct (non-interpolating) mapper?
virtual const scalarListList & weights() const
Return the interpolation weights.
Definition: FieldMapper.H:127
static const List< labelList > & null()
Return a null List.
Definition: ListI.H:130
virtual const labelUList & directAddressing() const
Return the direct addressing values.
Definition: FieldMapper.H:91
virtual label size() const =0
The size of the mapper.
Abstract base class to hold the Field mapping addressing and weights.
Definition: FieldMapper.H:43
Generic templated field type.
Definition: Field.H:62
errorManip< error > abort(error &err)
Definition: errorManip.H:139
virtual bool hasUnmapped() const =0
Any unmapped values?
virtual const mapDistributeBase & distributeMap() const
Return the distribution map.
Definition: FieldMapper.H:103
Class containing processor-to-processor mapping information.
virtual bool distributed() const
Does the mapper have remote contributions?
Definition: FieldMapper.H:76
static const UList< label > & null()
Return a UList reference to a nullObject.
Definition: UListI.H:90
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
tmp< Field< Type > > operator()(const Field< Type > &fld) const
Perform mapping on the given field.
Definition: FieldMapper.H:143
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Namespace for OpenFOAM.