40#ifndef Foam_AMICache_H
41#define Foam_AMICache_H
80 point rotationCentre_;
83 label nThetaStencilMax_;
93 mutable bool toSource_;
102 scalar interpWeight_;
139 scalar getRotationAngle(
const point& globalPoint)
const;
151 AMICache(
const bool toSource =
true);
165 const labelList& sourceRestrictAddressing,
166 const labelList& targetRestrictAddressing
204 const List<scalar>&
theta() const
noexcept {
return theta_; }
209 return cachedSrcAddress_;
215 return cachedSrcWeights_;
221 return cachedSrcWeightsSum_;
227 return cachedSrcMapPtr_;
233 return cachedTgtAddress_;
239 return cachedTgtWeights_;
245 return cachedTgtWeightsSum_;
251 return cachedTgtMapPtr_;
255 template<
class Type,
class EvalFunction>
261 return index0_ != -1 && index1_ == -1;
267 return index0_ == -1 && index1_ != -1;
273 return index0_ != -1 && index1_ != -1;
277 constexpr bool setDirection(
bool toSource)
const noexcept
279 toSource_ = toSource;
290 const point& globalPoint
296 if ((index < 0) || (index > size_-1))
299 <<
"Supplied out of bounds: " << index <<
"/"
325 #undef defineMethods01
326 #define defineMethods01(Src, Tgt, idx) \
327 const labelListList& c##Src##Address##idx() const \
329 checkBounds(index##idx##_); \
331 cached##Src##Address_[index##idx##_] \
332 : cached##Tgt##Address_[index##idx##_]; \
334 const scalarListList& c##Src##Weights##idx() const \
336 checkBounds(index##idx##_); \
338 cached##Src##Weights_[index##idx##_] \
339 : cached##Tgt##Weights_[index##idx##_]; \
341 const scalarField& c##Src##WeightsSum##idx() const \
343 checkBounds(index##idx##_); \
345 cached##Src##WeightsSum_[index##idx##_] \
346 : cached##Tgt##WeightsSum_[index##idx##_]; \
348 const autoPtr<mapDistribute>& c##Src##MapPtr##idx() const \
350 checkBounds(index##idx##_); \
352 cached##Src##MapPtr_[index##idx##_] \
353 : cached##Tgt##MapPtr_[index##idx##_]; \
364 #undef defineMethodsIndex
365 #define defineMethodsIndex(Src, Tgt) \
366 const labelListList& c##Src##Address(const label index) const \
368 checkBounds(index); \
370 cached##Src##Address_[index] \
371 : cached##Tgt##Address_[index]; \
373 const scalarListList& c##Src##Weights(const label index) const \
375 checkBounds(index); \
377 cached##Src##Weights_[index] \
378 : cached##Tgt##Weights_[index]; \
380 const scalarField& c##Src##WeightsSum(const label index) const \
382 checkBounds(index); \
384 cached##Src##WeightsSum_[index] \
385 : cached##Tgt##WeightsSum_[index]; \
387 const autoPtr<mapDistribute>& c##Src##MapPtr(const label index) \
390 checkBounds(index); \
392 cached##Src##MapPtr_[index] \
393 : cached##Tgt##MapPtr_[index]; \
#define defineMethods01(Src, Tgt, idx)
#define defineMethodsIndex(Src, Tgt)
constexpr bool applyUpper() const noexcept
Flag that upper bound is applicable.
const List< autoPtr< mapDistribute > > & cachedSrcMapPtr() const noexcept
Return List of source parallel maps.
const List< autoPtr< mapDistribute > > & cachedTgtMapPtr() const noexcept
Return List of target parallel maps.
constexpr bool setDirection(bool toSource) const noexcept
Set the interpolation direction.
void checkBounds(const label index) const
Check cache index is within bounds.
constexpr bool complete() const noexcept
Return true if cache is complete.
constexpr bool active() const noexcept
Return true if cache is active.
const List< labelListList > & cachedSrcAddress() const noexcept
Return List of source addresses.
constexpr label index1() const noexcept
Return cache upper bound index.
bool writeData(Ostream &os) const
Write AMI raw.
const List< scalarField > & cachedSrcWeightsSum() const noexcept
Return List of source weights sums.
static scalar cacheThetaTolerance_
Tolerance used when caching the AMI to identify e.g. if the current rotation angle has already been c...
const List< scalarListList > & cachedSrcWeights() const noexcept
Return List of source weights.
virtual ~AMICache()=default
Destructor.
constexpr bool applyInterpolate() const noexcept
Flag that interpolation is applicable.
void write(Ostream &os) const
Write AMI as a dictionary.
constexpr bool applyLower() const noexcept
Flag that lower bound is applicable.
constexpr label size() const noexcept
Return cache size.
label thetaIndex(const scalar theta) const noexcept
Return bin index for angle theta.
bool validIndex(const label bini) const
Return true of the cache index is set for bini.
const List< scalarField > & cachedTgtWeightsSum() const noexcept
Return List of target weights sums.
void addToCache(const AMIInterpolation &ami, const point &globalPoint)
Add AMI weights and addressing to the cache.
bool apply(List< Type > &result, const EvalFunction &eval) const
Apply cached evaluation based on user supplied evaluation function.
const List< scalar > & theta() const noexcept
Return list of cached rotation angles.
void setSize(const label size) noexcept
Set the cache size; also deactivates the cache if size <= 0.
bool restoreCache(const point &globalPoint)
Restore AMI weights and addressing from the cache.
const List< scalarListList > & cachedTgtWeights() const noexcept
Return List of target weights.
constexpr label weight() const noexcept
Return cache interpolation weight.
constexpr label index0() const noexcept
Return cache lower bound index.
AMICache(const bool toSource=true)
Null constructor.
const List< labelListList > & cachedTgtAddress() const noexcept
Return List of target addresses.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Macro definitions for declaring ClassName(), NamespaceName(), etc.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
constexpr scalar twoPi(2 *M_PI)
List< label > labelList
A List of labels.
errorManip< error > abort(error &err)
vector point
Point is a vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.