Skip to content
Snippets Groups Projects
Commit 49d76246 authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

added missing Rot3 to VTK output

parent 532940dd
No related merge requests found
......@@ -59,6 +59,14 @@ void writeOutput(std::ostream& os, const Vec3& data, const uint_t component)
walberla::vtk::toStream(os, data[component]);
}
template <>
inline
void writeOutput(std::ostream& os, const Rot3& data, const uint_t component)
{
WALBERLA_ASSERT_LESS(component, 3);
walberla::vtk::toStream(os, (data.getMatrix() * Vec3(1_r, 0_r, 0_r))[component]);
}
template <typename T>
inline
void writeOutput(walberla::vtk::Base64Writer& b64, const T& data, const uint_t component)
......@@ -85,6 +93,14 @@ void writeOutput(walberla::vtk::Base64Writer& b64, const Vec3& data, const uint_
b64 << data[component];
}
template <>
inline
void writeOutput(walberla::vtk::Base64Writer& b64, const Rot3& data, const uint_t component)
{
WALBERLA_ASSERT_LESS(component, 3);
b64 << (data.getMatrix() * Vec3(1_r, 0_r, 0_r))[component];
}
} // namespace vtk
} // namespace pe
} // namespace walberla
......@@ -21,6 +21,7 @@
#pragma once
#include <core/DataTypes.h>
#include <core/math/Rot3.h>
#include <core/math/Vector3.h>
namespace walberla {
......@@ -117,5 +118,13 @@ struct VTKTrait<math::Vector3<T>>
constexpr static const uint_t components = 3;
};
template <typename T>
struct VTKTrait<math::Rot3<T>>
{
using type = typename VTKTrait<T>::type;
constexpr static char const * const type_string = VTKTrait<T>::type_string;
constexpr static const uint_t components = 3;
};
} // namespace vtk
} // namespace walberla
......@@ -26,6 +26,7 @@
#include <core/Environment.h>
#include <core/grid_generator/SCIterator.h>
#include <core/logging/Logging.h>
#include <core/math/Constants.h>
#include <core/math/Random.h>
#include <vtk/VTKOutput.h>
......@@ -50,6 +51,8 @@ int main( int argc, char ** argv )
Vector3<uint_t>(2,2,2),
Vector3<bool>(false, false, false) );
auto rank = mpi::MPIManager::instance()->rank();
//initialize particles
const Vec3 shift(real_t(0.5), real_t(0.5), real_t(0.5));
for (auto& iBlk : *forest)
......@@ -61,15 +64,16 @@ int main( int argc, char ** argv )
auto p = ps->create();
p->setPosition( pt );
p->setOwner( mpi::MPIManager::instance()->rank() );
p->getRotationRef().rotate(Vec3(0_r,1_r,0_r), real_c(rank) * math::pi * 0.5_r);
}
}
auto vtkOutput = make_shared<mesa_pd::vtk::ParticleVtkOutput>(ps);
vtkOutput->addOutput<data::SelectParticleOwner>("owner");
vtkOutput->addOutput<data::SelectParticleLinearVelocity>("velocity");
auto rank = mpi::MPIManager::instance()->rank();
vtkOutput->addOutput<data::SelectParticleRotation>("rotation");
vtkOutput->setParticleSelector( [rank](const data::ParticleStorage::iterator& pIt) {return pIt->getIdx() < uint_c(rank);} );
auto vtkWriter = walberla::vtk::createVTKOutput_PointData(vtkOutput, "Bodies", 1, "vtk", "simulation_step", false, false);
auto vtkWriter = walberla::vtk::createVTKOutput_PointData(vtkOutput, "particles", 1, "vtk_outputs", "simulation_step", false, false);
vtkWriter->write();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment