OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::AnalyticalVelocityVolumeF< T > Class Template Referencefinal

#include <analyticalVelocityVolumeF.h>

+ Inheritance diagram for olb::AnalyticalVelocityVolumeF< T >:
+ Collaboration diagram for olb::AnalyticalVelocityVolumeF< T >:

Public Member Functions

 AnalyticalVelocityVolumeF (std::string fileName)
 
Vector< T, 3 > getPhysShape () const
 
getSpacing () const
 
bool operator() (T output[], const T physR[]) override
 
- Public Member Functions inherited from olb::AnalyticalF< 3, T, T >
AnalyticalF< D, T, T > & operator- (AnalyticalF< D, T, T > &rhs)
 
AnalyticalF< D, T, T > & operator+ (AnalyticalF< D, T, T > &rhs)
 
AnalyticalF< D, T, T > & operator* (AnalyticalF< D, T, T > &rhs)
 
AnalyticalF< D, T, T > & operator/ (AnalyticalF< D, T, T > &rhs)
 
- Public Member Functions inherited from olb::GenericF< T, S >
virtual ~GenericF ()=default
 
int getSourceDim () const
 read only access to member variable _m
 
int getTargetDim () const
 read only access to member variable _n
 
std::string & getName ()
 read and write access to name
 
std::string const & getName () const
 read only access to name
 
virtual bool operator() (T output[], const S input[])=0
 has to be implemented for 'every' derived class
 
bool operator() (T output[])
 wrapper that call the pure virtual operator() (T output[], const S input[]) from above
 
bool operator() (T output[], S input0)
 
bool operator() (T output[], S input0, S input1)
 
bool operator() (T output[], S input0, S input1, S input2)
 
bool operator() (T output[], S input0, S input1, S input2, S input3)
 

Additional Inherited Members

- Public Types inherited from olb::AnalyticalF< 3, T, T >
using identity_functor_type
 
- Public Types inherited from olb::GenericF< T, S >
using targetType = T
 
using sourceType = S
 
- Public Attributes inherited from olb::GenericF< T, S >
std::shared_ptr< GenericF< T, S > > _ptrCalcC
 memory management, frees resouces (calcClass)
 
- Static Public Attributes inherited from olb::AnalyticalF< 3, T, T >
static constexpr unsigned dim
 
- Protected Member Functions inherited from olb::AnalyticalF< 3, T, T >
 AnalyticalF (int n)
 
- Protected Member Functions inherited from olb::GenericF< T, S >
 GenericF (int targetDim, int sourceDim)
 

Detailed Description

template<typename T>
class olb::AnalyticalVelocityVolumeF< T >

Definition at line 39 of file analyticalVelocityVolumeF.h.

Constructor & Destructor Documentation

◆ AnalyticalVelocityVolumeF()

template<typename T >
olb::AnalyticalVelocityVolumeF< T >::AnalyticalVelocityVolumeF ( std::string fileName)
inline

Definition at line 56 of file analyticalVelocityVolumeF.h.

57 : AnalyticalF<3,T,T>(3)
58 {
59 this->getName() = "VelocityVolumeImporter";
60
61 OstreamManager clout(std::cout, "VelocityVolumeImporter");
62 _fileName = fileName;
63
64 #if not defined(FEATURE_VTK)
65 if (isVTIFile(_fileName))
66 {
67 std::cerr << "To use the VTK format, add VTK to the FEATURES list in config.mk";
68 exit(1);
69 }
70 #endif
71 #if defined(FEATURE_VTK)
72 if (!isVTIFile(_fileName)) {
73 std::cerr << "Please convert your file to .vti to use the functor.";
74 exit(1);
75 } else {
76 clout << "Read .vti file..." << std::endl;
77 _reader->SetFileName(fileName.c_str());
78 _reader->Update();
79 auto* _data = _reader->GetOutput();
80
81 _spacing = static_cast<T>(_data->GetSpacing()[0]);
82 clout << "Read spacing : " << _spacing << std::endl;
83 _data->GetDimensions(_shape.data());
84 clout << "Read shape : " << _shape << std::endl;
85 _data->GetOrigin(_origin.data());
86 clout << "Read origin : " << _origin << std::endl;
87
88 vtkCellData* _cellData = _data->GetCellData();
89 vtkPointData* _pointData = _data->GetPointData();
90 if (_cellData->GetNumberOfArrays() > 0) {
91 clout << "Found CellData. " << std::endl;
92 CellData = true;
93 _cellLocator->SetDataSet(_data);
94 _cellLocator->BuildLocator();
95 } else if (_pointData->GetNumberOfArrays() > 0) {
96 clout << "Found PointData." << std::endl;
97 clout << "Warning: If functor reads only 0, consider converting PointData to CellData." << std::endl;
98 PointData = true;
99 } else {
100 std::cerr << "Neither cell data nor point data found.";
101 exit(1);
102 }
103 }
104 #endif
105 }
std::string & getName()
read and write access to name
Definition genericF.hh:51
constexpr const T * data() const any_platform
Definition vector.h:161
void exit(int exitcode)
Definition singleton.h:165

References olb::Vector< T, D >::data(), and olb::GenericF< T, S >::getName().

+ Here is the call graph for this function:

Member Function Documentation

◆ getPhysShape()

template<typename T >
Vector< T, 3 > olb::AnalyticalVelocityVolumeF< T >::getPhysShape ( ) const
inline

Definition at line 107 of file analyticalVelocityVolumeF.h.

107 {
108 return _shape * _spacing;
109 }

◆ getSpacing()

template<typename T >
T olb::AnalyticalVelocityVolumeF< T >::getSpacing ( ) const
inline

Definition at line 111 of file analyticalVelocityVolumeF.h.

111 {
112 return _spacing;
113 }

◆ operator()()

template<typename T >
bool olb::AnalyticalVelocityVolumeF< T >::operator() ( T output[],
const T physR[] )
inlineoverride

Definition at line 115 of file analyticalVelocityVolumeF.h.

115 {
116 #if defined(FEATURE_VTK)
117 if (!isInside(physR)) {
118 //std::cout << "Point outside." << std::endl;
119 output[0] = 0;
120 output[1] = 0;
121 output[2] = 0;
122 return true;
123 }
124
125 auto* _data = _reader->GetOutput();
126
127 // cell data (preferred)
128 if (CellData) {
129 vtkCellData* _cellData = _data->GetCellData();
130 // Assuming cellData holds the velocity data in the first array
131 vtkDataArray* _vectors = _cellData->GetVectors(_cellData->GetArrayName(0));
132 if (_vectors == nullptr) {
133 std::cerr << "[AnalyticalVelocityVolumeF]: ";
134 std::cerr << "Cell data: No vector data was found." << std::endl;
135 exit(1);
136 }
137
138 double x[3] = {physR[0], physR[1], physR[2]};
139 vtkIdType cellId = _cellLocator->FindCell(x);
140 if (cellId >= 0) {
141 double velocity[3] = {};
142 _vectors->GetTuple(cellId, velocity);
143 for (int dim = 0; dim < 3; ++dim) {
144 output[dim] = static_cast<T>(velocity[dim]);
145 }
146 } else {
147 //std::cout << "Cell not found." << std::endl;
148 output[0] = 0;
149 output[1] = 0;
150 output[2] = 0;
151 }
152 }
153
154 // point data (can cause problems due to round-off)
155 else if (PointData) {
156 vtkPointData* _pointData = _data->GetPointData();
157 // Assuming pointData holds the velocity data in the first array
158 vtkDataArray* _vectors = _pointData->GetVectors(_pointData->GetArrayName(0));
159 if (_vectors == nullptr) {
160 std::cerr << "[AnalyticalVelocityVolumeF]: ";
161 std::cerr << "Point data: No vector data was found." << std::endl;
162 return false;
163 }
164
165 Vector<int,3> x = getVtiLatticeR(physR);
166 vtkIdType pointId = _data->FindPoint(x[0], x[1], x[2]);
167 if (pointId >= 0) {
168 double velocity[3] = {};
169 _vectors->GetTuple(pointId, velocity);
170 for (int dim = 0; dim < 3; ++dim) {
171 output[dim] = static_cast<T>(velocity[dim]);
172 }
173 } else {
174 //std::cout << "Point not found." << std::endl;
175 output[0] = 0;
176 output[1] = 0;
177 output[2] = 0;
178 }
179 }
180 #endif
181 return true;
182 }
static constexpr unsigned dim

References olb::AnalyticalF< 3, T, T >::dim.


The documentation for this class was generated from the following file: