FEDEM Solver  R8.0
Source code of the dynamics solver
FFrVariableReference.H
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2023 SAP SE
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // This file is part of FEDEM - https://openfedem.org
7 
8 #ifndef FFR_VARIABLE_REFERENCE_H
9 #define FFR_VARIABLE_REFERENCE_H
10 
11 #include "FFrLib/FFrEntryBase.H"
12 
13 class FFaOperationBase;
14 class FFrVariable;
15 
16 
18 {
19 public:
20 #if FFR_DEBUG > 2
23  virtual ~FFrVariableReference();
24 #else
26  virtual ~FFrVariableReference() {}
27 #endif
28 
29  virtual const std::string& getDescription() const;
30  virtual const std::string& getType() const;
31 
32  virtual bool isVariableFloat() const;
33  virtual bool isVarRef() const { return true; }
34  virtual bool isEmpty() const { return containers.empty(); }
35 
37 
39  unsigned int getTimeStamp() const;
40 
41  // If usePositionedKey is true, the current physical position of the
42  // owning extractor object is used in the following two functions.
43  // If usePositionedKey is false, the requested position is used.
44  double getDistanceFromResultPoint(const bool usePositionedKey = false) const;
45  bool hasDataForCurrentKey(const bool usePositionedKey = false) const;
46 
47  void getValidKeys(std::set<double>& validValues) const;
48 
50  virtual void printPosition(std::ostream& os) const;
51 
52  union {
54  FFrVariableReference* next; // used in memory management
55  };
56 
57  typedef std::pair<FFrResultContainer*,size_t> FFrResultContainerRef;
58 
59  std::vector<FFrResultContainerRef> containers;
60 
61  virtual void removeContainers(const std::set<FFrResultContainer*>& cont);
62 
63  virtual int traverse(FFrResultContainer* resultContainer,
64  FFrEntryBase* owner,
65  FFrEntryBase*& objToBeModified,
66  int binPos);
67 
68  virtual bool merge(FFrEntryBase* obj);
69  virtual bool compare(const FFrEntryBase* obj) const { return this->equal(obj); }
70  virtual bool equal(const FFrEntryBase* obj) const;
71  virtual bool less(const FFrEntryBase* obj) const;
72 
73 protected:
74  virtual int recursiveReadPosData(const double* vals, int nvals, int arrayPos) const;
75  virtual int recursiveReadPosData(const float* vals, int nvals, int arrayPos) const;
76  virtual int recursiveReadPosData(const int* vals, int nvals, int arrayPos) const;
77 
78 private:
81  int getNearestContainer() const;
82 
83 #ifdef FFR_NEWALLOC
84 public:
85  // overloading the new & delete operators
86  static void* operator new(size_t size);
87  static void operator delete(void* deadObject, size_t size);
88 
89  static void releaseMemBlocks();
90 
91 private:
92  static size_t newed;
93  static FFrVariableReference* headOfFreeList;
94  static std::vector<FFrVariableReference*> memBlocks;
95 #endif
96 #if FFR_DEBUG > 2
97  static long int count;
98 #endif
99 };
100 
101 #endif
Base class for all operations.
Definition: FFaOperation.H:38
Definition: FFrEntryBase.H:28
Class holding the data of a Fedem results file.
Definition: FFrResultContainer.H:71
Definition: FFrVariableReference.H:18
int getNearestContainer() const
Returns the index of the nearest container for the current setting.
Definition: FFrVariableReference.C:109
virtual void removeContainers(const std::set< FFrResultContainer * > &cont)
Definition: FFrVariableReference.C:98
unsigned int getTimeStamp() const
Returns the (most recent) time stamp of this variable.
Definition: FFrVariableReference.C:215
bool hasDataForCurrentKey(const bool usePositionedKey=false) const
Definition: FFrVariableReference.C:259
virtual bool isEmpty() const
Returns true if this entry and all below it are empty.
Definition: FFrVariableReference.H:34
FFrVariableReference * next
Definition: FFrVariableReference.H:54
virtual ~FFrVariableReference()
Definition: FFrVariableReference.H:26
virtual bool less(const FFrEntryBase *obj) const
Definition: FFrVariableReference.C:91
std::pair< FFrResultContainer *, size_t > FFrResultContainerRef
Definition: FFrVariableReference.H:57
virtual bool isVariableFloat() const
Returns true if the first variable referred is a float.
Definition: FFrVariableReference.C:203
double getDistanceFromResultPoint(const bool usePositionedKey=false) const
Definition: FFrVariableReference.C:236
FFrVariable * variableDescr
Definition: FFrVariableReference.H:53
virtual bool equal(const FFrEntryBase *obj) const
Definition: FFrVariableReference.C:84
virtual int traverse(FFrResultContainer *resultContainer, FFrEntryBase *owner, FFrEntryBase *&objToBeModified, int binPos)
Traverses to build owner hierarchy and calculate binary sizes.
Definition: FFrVariableReference.C:55
virtual void printPosition(std::ostream &os) const
Prints out the positioning data of this variable.
Definition: FFrVariableReference.C:277
void getValidKeys(std::set< double > &validValues) const
Definition: FFrVariableReference.C:266
virtual bool compare(const FFrEntryBase *obj) const
Definition: FFrVariableReference.H:69
virtual const std::string & getType() const
Definition: FFrVariableReference.C:49
FFaOperationBase * getReadOperation()
Definition: FFrVariableReference.C:209
virtual const std::string & getDescription() const
Definition: FFrVariableReference.C:43
virtual bool merge(FFrEntryBase *obj)
Definition: FFrVariableReference.C:72
virtual int recursiveReadPosData(const double *vals, int nvals, int arrayPos) const
Definition: FFrVariableReference.C:143
virtual bool isVarRef() const
Definition: FFrVariableReference.H:33
FFrVariableReference(FFrVariable *var)
Definition: FFrVariableReference.H:25
std::vector< FFrResultContainerRef > containers
Definition: FFrVariableReference.H:59
Definition: FFrVariable.H:22