Reply To: Rotating cuboid not working correctly in 1.8
OpenLB – Open Source Lattice Boltzmann Code › Forums › on OpenLB › Bug Reports › Rotating cuboid not working correctly in 1.8 › Reply To: Rotating cuboid not working correctly in 1.8
June 18, 2025 at 2:13 pm
#10374
upqdb
Participant
Hello,
the problem does not actually come from wrong rotation. In the current version, both the IndicatorCuboid2D class and the IndicatorRotate class have their bounding boxes not respecting the rotation correctly, this results in the geometry being cut off. This problem was already noticed and fixed, however it is not yet in the release branch.
For now I will provide you the updated getMin and getMax functions for the IndicatorRotate Class.
template <typename S, unsigned D>
Vector<S,D>& IndicatorRotate<S,D>::getMin()
{
if constexpr (D == 2){
const S inMin[2] = {_indicator.getMin()[0], _indicator.getMin()[1]};
const S inMax[2] = {_indicator.getMax()[0], _indicator.getMax()[1]};
const S radius = util::sqrt(util::pow(inMax[0] - inMin[0], 2) + util::pow(inMax[1] - inMin[1], 2));
_min[0] = _rotationPoint[0] - radius;
_min[1] = _rotationPoint[1] - radius;
return _min;
}
else if constexpr (D == 3){
const S inMin[3] = {_indicator.getMin()[0], _indicator.getMin()[1], _indicator.getMin()[2]};
const S inMax[3] = {_indicator.getMax()[0], _indicator.getMax()[1], _indicator.getMax()[2]};
const S radius = util::sqrt(util::pow(inMax[0] - inMin[0], 2) + util::pow(inMax[1] - inMin[1], 2) + util::pow(inMax[2] - inMin[2], 2));
_min[0] = _rotationPoint[0] - radius;
_min[1] = _rotationPoint[1] - radius;
_min[2] = _rotationPoint[2] - radius;
return _min;
}
}
template <typename S, unsigned D>
Vector<S,D>& IndicatorRotate<S,D>::getMax()
{
if constexpr (D == 2){
const S inMin[2] = {_indicator.getMin()[0], _indicator.getMin()[1]};
const S inMax[2] = {_indicator.getMax()[0], _indicator.getMax()[1]};
const S radius = util::sqrt(util::pow(inMax[0] - inMin[0], 2) + util::pow(inMax[1] - inMin[1], 2));
_max[0] = _rotationPoint[0] + radius;
_max[1] = _rotationPoint[1] + radius;
return _max;
}
else if constexpr (D == 3){
const S inMin[3] = {_indicator.getMin()[0], _indicator.getMin()[1], _indicator.getMin()[2]};
const S inMax[3] = {_indicator.getMax()[0], _indicator.getMax()[1], _indicator.getMax()[2]};
const S radius = util::sqrt(util::pow(inMax[0] - inMin[0], 2) + util::pow(inMax[1] - inMin[1], 2) + util::pow(inMax[2] - inMin[2], 2));
_max[0] = _rotationPoint[0] + radius;
_max[1] = _rotationPoint[1] + radius;
_max[2] = _rotationPoint[2] + radius;
return _max;
}
}
This should fix your problem, please report if you run into any more issues!