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 | Copyright (C) 2011-2013 OpenFOAM Foundation
6  \\/ M anipulation |
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::FieldMapper
26 
27 Description
28  Abstract base class to hold the Field mapping addressing and weights.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #ifndef FieldMapper_H
33 #define FieldMapper_H
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 /*---------------------------------------------------------------------------*\
41  Class FieldMapper Declaration
42 \*---------------------------------------------------------------------------*/
43 
44 class FieldMapper
45 {
46 
47 public:
48 
49  // Constructors
50 
51  //- Null constructor
52  FieldMapper()
53  {}
54 
55 
56  //- Destructor
57  virtual ~FieldMapper()
58  {}
59 
60 
61  // Member Functions
62 
63  virtual label size() const = 0;
64 
65  virtual bool direct() const = 0;
66 
67  //- Are there unmapped values? I.e. do all size() elements get
68  // get value
69  virtual bool hasUnmapped() const = 0;
70 
71  virtual const labelUList& directAddressing() const
72  {
73  FatalErrorIn("FieldMapper::directAddressing() const")
74  << "attempt to access null direct addressing"
75  << abort(FatalError);
76 
77  return labelUList::null();
78  }
79 
80  virtual const labelListList& addressing() const
81  {
82  FatalErrorIn("FieldMapper::addressing() const")
83  << "attempt to access null interpolation addressing"
84  << abort(FatalError);
85 
86  return labelListList::null();
87  }
88 
89  virtual const scalarListList& weights() const
90  {
91  FatalErrorIn("FieldMapper::weights() const")
92  << "attempt to access null interpolation weights"
93  << abort(FatalError);
94 
95  return scalarListList::null();
96  }
97 
98 
99  // Member Operators
100 
101  template<class Type>
102  tmp<Field<Type> > operator()(const Field<Type>& f) const
103  {
104  return tmp<Field<Type> >(new Field<Type>(f, *this));
105  }
106 };
107 
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 } // End namespace Foam
112 
113 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114 
115 #endif
116 
117 // ************************************************************************* //
static const UList< T > & null()
Return a null UList.
Definition: UListI.H:51
labelList f(nPoints)
virtual ~FieldMapper()
Destructor.
Definition: FieldMapper.H:56
Abstract base class to hold the Field mapping addressing and weights.
Definition: FieldMapper.H:43
static const List< labelList > & null()
Return a null List.
tmp< Field< Type > > operator()(const Field< Type > &f) const
Definition: FieldMapper.H:101
virtual const scalarListList & weights() const
Definition: FieldMapper.H:88
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
Namespace for OpenFOAM.
Pre-declare SubField and related Field type.
Definition: Field.H:57
errorManip< error > abort(error &err)
Definition: errorManip.H:131
virtual label size() const =0
virtual const labelUList & directAddressing() const
Definition: FieldMapper.H:70
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
FieldMapper()
Null constructor.
Definition: FieldMapper.H:51
error FatalError
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
virtual const labelListList & addressing() const
Definition: FieldMapper.H:79
virtual bool direct() const =0
virtual bool hasUnmapped() const =0
Are there unmapped values? I.e. do all size() elements get.
A class for managing temporary objects.
Definition: PtrList.H:118