161 int flag_observables) {
163 auto const unit_conversion = FloatType_c(units.at(
"density"));
164 auto const blocks = m_lattice->get_blocks();
165 WALBERLA_ASSERT_NOT_NULLPTR(blocks);
166 auto density_writer = std::make_shared<DensityVTKWriter<FloatType, float>>(
167 m_pdf_field_id,
"density", unit_conversion);
168 auto before_function = [
this, blocks, density_writer]() {
169 for (
auto &
block : *blocks) {
170 auto *pdf_field =
block.template getData<PdfField>(m_pdf_field_id);
171 auto const bci = pdf_field->xyzSize();
172 density_writer->set_content(
174 density_writer->set_dims(
175 Vector3<uint_t>(bci.xSize(), bci.ySize(), bci.zSize()));
178 vtk_obj.addBeforeFunction(std::move(before_function));
179 vtk_obj.addCellDataWriter(density_writer);
182 auto const unit_conversion = FloatType_c(units.at(
"velocity"));
183 auto const blocks = m_lattice->get_blocks();
184 WALBERLA_ASSERT_NOT_NULLPTR(blocks);
185 auto velocity_writer =
186 std::make_shared<VelocityVTKWriter<FloatType, float>>(
187 m_pdf_field_id,
"velocity_vector", unit_conversion);
188 auto before_function = [
this, blocks, velocity_writer]() {
189 for (
auto &
block : *blocks) {
190 auto *velocity_field =
191 block.template getData<VectorField>(m_velocity_field_id);
193 auto const offset = m_lattice->get_block_corner(
block,
true);
194 auto const *flag_field =
195 block.template getData<FlagField>(m_flag_field_id);
196 auto const boundary_flag = flag_field->getFlag(Boundary_flag);
197 WALBERLA_FOR_ALL_CELLS_XYZ(flag_field, {
198 if (flag_field->isFlagSet(x, y, z, boundary_flag)) {
199 Cell const global(offset[0] + x, offset[1] + y, offset[2] + z);
200 auto const &vel = m_boundary->get_node_value_at_boundary(global);
201 Cell const local(x, y, z);
202 lbm::accessor::Vector::set(velocity_field, vel, local);
206 auto const bci = velocity_field->xyzSize();
207 velocity_writer->set_content(
209 velocity_writer->set_dims(
210 Vector3<uint_t>(bci.xSize(), bci.ySize(), bci.zSize()));
214 vtk_obj.addBeforeFunction(std::move(before_function));
215 vtk_obj.addCellDataWriter(velocity_writer);
218 auto const unit_conversion = FloatType_c(units.at(
"pressure"));
219 auto const blocks = m_lattice->get_blocks();
220 WALBERLA_ASSERT_NOT_NULLPTR(blocks);
221 auto pressure_writer =
222 std::make_shared<PressureTensorVTKWriter<FloatType, float>>(
223 m_pdf_field_id,
"pressure_tensor", unit_conversion);
224 auto before_function = [
this, blocks, pressure_writer]() {
225 for (
auto &
block : *blocks) {
226 auto *pdf_field =
block.template getData<PdfField>(m_pdf_field_id);
227 auto const bci = pdf_field->xyzSize();
230 for (std::size_t n = 0u; n < values.size(); n += 9u) {
231 pressure_tensor_correction(
232 std::span<FloatType, 9ul>(&values[n], 9ul));
234 pressure_writer->set_content(std::move(values));
235 pressure_writer->set_dims(
236 Vector3<uint_t>(bci.xSize(), bci.ySize(), bci.zSize()));
239 vtk_obj.addBeforeFunction(std::move(before_function));
240 vtk_obj.addCellDataWriter(pressure_writer);
243 vtk_obj.addCellDataWriter(
245 m_flag_field_id,
"boundary", Boundary_flag));