Skip to content

Reply To: Modifying field values for neighboring cells inside a postprocessor

OpenLB – Open Source Lattice Boltzmann Code Forums on OpenLB General Topics Modifying field values for neighboring cells inside a postprocessor Reply To: Modifying field values for neighboring cells inside a postprocessor

#9100
Danial.Khazaeipoul
Participant

FYI, as also stated in the user-guide, the standard C++ std::vector container does not work with CUDA but it is still used within the “freeSurfaceHelpers.hh” where the calculateCubeOffset function is defined.

template<typename T, typename DESCRIPTOR>
static T calculateCubeOffset(T volume, const Vector<T,DESCRIPTOR::d>& normal) any_platform;

template<typename T, typename DESCRIPTOR>
T calculateCubeOffset(T volume, const Vector<T,DESCRIPTOR::d>& normal) {
std::vector<T> abs_normal(DESCRIPTOR::d, T{0});
for(int i = 0; i < DESCRIPTOR::d; i++){
abs_normal[i] = util::abs(normal[i]);
}

T volume_symmetry = 0.5 – util::abs(volume – 0.5);

std::sort(abs_normal.begin(), abs_normal.end());

if constexpr (DESCRIPTOR::d == 2) {
abs_normal[0] = util::max(normal[0], 1e-5);
} else if (DESCRIPTOR::d == 3){
abs_normal[0] = util::max(normal[0], 1e-12);
abs_normal[1] = util::max(normal[1], 1e-12);
}

T d = offsetHelper<T,DESCRIPTOR>(volume_symmetry, abs_normal);

T sorted_normal_acc = 0;
for(int i = 0; i < DESCRIPTOR::d; i++){
sorted_normal_acc += abs_normal[i];
}

return std::copysign(d – 0.5 * sorted_normal_acc, volume – 0.5);
}

P.S. this is the original code from olb-1.7r0.