interpolationWeights.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) 2012-2016 OpenFOAM Foundation
9  Copyright (C) 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::interpolationWeights
29 
30 Description
31  Abstract base class for interpolating in 1D
32 
33 SourceFiles
34  interpolationWeights.C
35  interpolationWeightsTemplates.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef interpolationWeights_H
40 #define interpolationWeights_H
41 
42 #include "scalarField.H"
43 #include "autoPtr.H"
44 #include "runTimeSelectionTables.H"
45 #include "pointField.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 class fvMesh;
53 class objectRegistry;
54 
55 /*---------------------------------------------------------------------------*\
56  Class interpolationWeights Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 {
61 protected:
62 
63  // Protected Data
64 
65  const scalarField& samples_;
66 
67 
68  // Protected Member Functions
69 
70  //- No copy construct
72 
73  //- No copy assignment
74  void operator=(const interpolationWeights&) = delete;
75 
76 
77 public:
78 
79  //- Runtime type information
80  TypeName("interpolationWeights");
81 
82 
83  // Declare run-time constructor selection table
84 
86  (
87  autoPtr,
89  word,
90  (
91  const scalarField& samples
92  ),
93  (samples)
94  );
95 
96 
97  // Constructors
98 
99  //- Construct from components
100  explicit interpolationWeights(const scalarField& samples);
101 
102 
103  // Selectors
104 
105  //- Return a reference to the selected interpolationWeights
107  (
108  const word& type,
109  const scalarField& samples
110  );
111 
112 
113  //- Destructor
114  virtual ~interpolationWeights() = default;
115 
116 
117  // Member Functions
118 
119  //- Calculate weights and indices to calculate t from samples.
120  // Returns true if indices changed.
121  virtual bool valueWeights
122  (
123  const scalar t,
124  labelList& indices,
125  scalarField& weights
126  ) const = 0;
127 
128  //- Calculate weights and indices to calculate integrand of t1..t2
129  // from samples. Returns true if indices changed.
130  virtual bool integrationWeights
131  (
132  const scalar t1,
133  const scalar t2,
134  labelList& indices,
135  scalarField& weights
136  ) const = 0;
137 
138  //- Helper: weighted sum
139  template<class ListType1, class ListType2>
140  static typename outerProduct
141  <
142  typename ListType1::value_type,
143  typename ListType2::value_type
144  >::type
145  weightedSum(const ListType1& f1, const ListType2& f2);
146 
147 };
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 } // End namespace Foam
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 #ifdef NoRepository
157 #endif
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 #endif
162 
163 // ************************************************************************* //
Foam::interpolationWeights::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, interpolationWeights, word,(const scalarField &samples),(samples))
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::interpolationWeights::operator=
void operator=(const interpolationWeights &)=delete
No copy assignment.
scalarField.H
interpolationWeightsTemplates.C
Foam::interpolationWeights::weightedSum
static outerProduct< typename ListType1::value_type, typename ListType2::value_type >::type weightedSum(const ListType1 &f1, const ListType2 &f2)
Helper: weighted sum.
Foam::Field< scalar >
samples
scalarField samples(nIntervals, Zero)
Foam::interpolationWeights
Abstract base class for interpolating in 1D.
Definition: interpolationWeights.H:58
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
pointField.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::interpolationWeights::New
static autoPtr< interpolationWeights > New(const word &type, const scalarField &samples)
Return a reference to the selected interpolationWeights.
Definition: interpolationWeights.C:53
Foam::interpolationWeights::valueWeights
virtual bool valueWeights(const scalar t, labelList &indices, scalarField &weights) const =0
Calculate weights and indices to calculate t from samples.
Foam::interpolationWeights::TypeName
TypeName("interpolationWeights")
Runtime type information.
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::interpolationWeights::integrationWeights
virtual bool integrationWeights(const scalar t1, const scalar t2, labelList &indices, scalarField &weights) const =0
Calculate weights and indices to calculate integrand of t1..t2.
Foam::List< label >
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::interpolationWeights::~interpolationWeights
virtual ~interpolationWeights()=default
Destructor.
Foam::interpolationWeights::samples_
const scalarField & samples_
Definition: interpolationWeights.H:64
Foam::interpolationWeights::interpolationWeights
interpolationWeights(const interpolationWeights &)=delete
No copy construct.
Foam::outerProduct
Definition: products.H:106
autoPtr.H