------------------------------------------------------------------------------
| 129 | |
| 130 | //------------------------------------------------------------------------------ |
| 131 | int vtkAMRInterpolatedVelocityField::FunctionValues(double* x, double* f) |
| 132 | { |
| 133 | if (this->LastDataSet && this->FunctionValues(this->LastDataSet, x, f)) |
| 134 | { |
| 135 | return 1; |
| 136 | } |
| 137 | |
| 138 | // Either we do not know which data set it is, or existing LastDataSet does not contain x |
| 139 | // In any case, set LastDataSet to nullptr and try to find a new one |
| 140 | this->LastDataSet = nullptr; |
| 141 | this->LastCellId = -1; |
| 142 | this->LastLevel = -1; |
| 143 | this->LastId = -1; |
| 144 | |
| 145 | unsigned int level, gridId; |
| 146 | if (!FindGrid(x, this->AmrDataSet, level, gridId)) |
| 147 | { |
| 148 | return 0; |
| 149 | } |
| 150 | this->LastLevel = level; |
| 151 | this->LastId = gridId; |
| 152 | |
| 153 | vtkCartesianGrid* cg = this->AmrDataSet->GetDataSetAsCartesianGrid(level, gridId); |
| 154 | if (!cg) |
| 155 | { |
| 156 | return 0; |
| 157 | } |
| 158 | if (!this->FunctionValues(cg, x, f)) |
| 159 | { |
| 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | this->LastDataSet = cg; |
| 164 | return 1; |
| 165 | } |
| 166 | |
| 167 | //------------------------------------------------------------------------------ |
| 168 | bool vtkAMRInterpolatedVelocityField::SetLastDataSet(int level, int id) |