59 this->
getName() =
"VelocityVolumeImporter";
64 #if not defined(FEATURE_VTK)
65 if (isVTIFile(_fileName))
67 std::cerr <<
"To use the VTK format, add VTK to the FEATURES list in config.mk";
71 #if defined(FEATURE_VTK)
72 if (!isVTIFile(_fileName)) {
73 std::cerr <<
"Please convert your file to .vti to use the functor.";
76 clout <<
"Read .vti file..." << std::endl;
77 _reader->SetFileName(fileName.c_str());
79 auto* _data = _reader->GetOutput();
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;
88 vtkCellData* _cellData = _data->GetCellData();
89 vtkPointData* _pointData = _data->GetPointData();
90 if (_cellData->GetNumberOfArrays() > 0) {
91 clout <<
"Found CellData. " << std::endl;
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;
100 std::cerr <<
"Neither cell data nor point data found.";
116 #if defined(FEATURE_VTK)
117 if (!isInside(physR)) {
125 auto* _data = _reader->GetOutput();
129 vtkCellData* _cellData = _data->GetCellData();
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;
138 double x[3] = {physR[0], physR[1], physR[2]};
139 vtkIdType cellId = _cellLocator->FindCell(x);
141 double velocity[3] = {};
142 _vectors->GetTuple(cellId, velocity);
144 output[
dim] =
static_cast<T
>(velocity[
dim]);
155 else if (PointData) {
156 vtkPointData* _pointData = _data->GetPointData();
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;
166 vtkIdType pointId = _data->FindPoint(x[0], x[1], x[2]);
168 double velocity[3] = {};
169 _vectors->GetTuple(pointId, velocity);
171 output[
dim] =
static_cast<T
>(velocity[
dim]);