Due to a key rollover of our WebSSO provider there might be a short downtime of this Gitlab server on Friday 2.

Commit c406935e authored by Lukas Werner's avatar Lukas Werner Committed by Sebastian Eibl

Support of convex meshes for MESA-PD

parent b831f070
......@@ -34,5 +34,4 @@ if ( WALBERLA_BUILD_WITH_PYTHON )
add_subdirectory( pythonmodule )
# no else with "EXLUDE_FROM_ALL" here, since if WALBERLA_BUILD_WITH_PYTHON_MODULE is not activated
# waLBerla was build without -fPIC , so no linking into shared library is possible
endif()
endif()
\ No newline at end of file
......@@ -24,53 +24,45 @@
#include "blockforest/communication/UniformBufferedScheme.h"
#include "blockforest/loadbalancing/StaticParMetis.h"
#include "core/SharedFunctor.h"
#include "core/Environment.h"
#include "core/SharedFunctor.h"
#include "core/logging/Logging.h"
#include "core/math/IntegerFactorization.h"
#include "core/timing/RemainingTimeLogger.h"
#include "domain_decomposition/SharedSweep.h"
#include "field/AddToStorage.h"
#include "field/StabilityChecker.h"
#include "geometry/InitBoundaryHandling.h"
#include "geometry/mesh/TriangleMesh.h"
#include "geometry/mesh/TriangleMeshIO.h"
#include "lbm/BlockForestEvaluation.h"
#include "lbm/PerformanceEvaluation.h"
#include "lbm/PerformanceLogger.h"
#include "lbm/boundary/factories/DefaultBoundaryHandling.h"
#include "lbm/communication/PdfFieldPackInfo.h"
#include "lbm/communication/SparsePdfFieldPackInfo.h"
#include "lbm/field/AddToStorage.h"
#include "lbm/lattice_model/CollisionModel.h"
#include "lbm/lattice_model/D3Q19.h"
#include "lbm/lattice_model/D3Q27.h"
#include "lbm/lattice_model/CollisionModel.h"
#include "lbm/lattice_model/ForceModel.h"
#include "lbm/refinement/TimeStep.h"
#include "lbm/sweeps/CellwiseSweep.h"
#include "lbm/sweeps/SplitPureSweep.h"
#include "lbm/vtk/VTKOutput.h"
#include "lbm/BlockForestEvaluation.h"
#include "lbm/PerformanceEvaluation.h"
#include "lbm/PerformanceLogger.h"
#include "geometry/mesh/TriangleMesh.h"
#include "geometry/mesh/TriangleMeshIO.h"
#include "geometry/InitBoundaryHandling.h"
#include "mesh_common/TriangleMeshes.h"
#include "mesh_common/MeshOperations.h"
#include "mesh_common/DistanceComputations.h"
#include "mesh_common/DistanceFunction.h"
#include "mesh_common/MeshIO.h"
#include "mesh_common/MatrixVectorOperations.h"
#include "mesh_common/distance_octree/DistanceOctree.h"
#include "mesh_common/vtk/VTKMeshWriter.h"
#include "mesh_common/vtk/CommonDataSources.h"
#include "mesh/blockforest/BlockExclusion.h"
#include "mesh/blockforest/BlockForestInitialization.h"
#include "mesh/blockforest/BlockWorkloadMemory.h"
#include "mesh/blockforest/BlockExclusion.h"
#include "mesh/blockforest/RefinementSelection.h"
#include "mesh/boundary/BoundarySetup.h"
#include "mesh/boundary/BoundaryInfo.h"
#include "mesh/boundary/BoundaryLocation.h"
#include "mesh/boundary/BoundaryLocationFunction.h"
#include "mesh/boundary/BoundarySetup.h"
#include "mesh/boundary/BoundaryUIDFaceDataSource.h"
#include "mesh/boundary/ColorToBoundaryMapper.h"
......@@ -78,11 +70,19 @@
#include "timeloop/SweepTimeloop.h"
#include "core/timing/RemainingTimeLogger.h"
#include <cmath>
#include <vector>
#include <string>
#include <vector>
#include "mesh_common/DistanceComputations.h"
#include "mesh_common/DistanceFunction.h"
#include "mesh_common/MatrixVectorOperations.h"
#include "mesh_common/MeshIO.h"
#include "mesh_common/MeshOperations.h"
#include "mesh_common/TriangleMeshes.h"
#include "mesh_common/distance_octree/DistanceOctree.h"
#include "mesh_common/vtk/CommonDataSources.h"
#include "mesh_common/vtk/VTKMeshWriter.h"
namespace walberla {
......
......@@ -2,6 +2,7 @@ add_subdirectory( BidisperseFluidizedBed )
add_subdirectory( CombinedResolvedUnresolved )
add_subdirectory( HeatConduction )
add_subdirectory( Mixer )
add_subdirectory( PegIntoSphereBed )
if ( WALBERLA_BUILD_WITH_CODEGEN)
add_subdirectory( PhaseFieldAllenCahn )
endif()
waLBerla_link_files_to_builddir( *.cfg )
if (OPENMESH_FOUND AND WALBERLA_MESAPD_CONVEX_POLYHEDRON_AVAILABLE)
waLBerla_add_executable ( NAME MESA_PD_MESH_APP_PegIntoSphereBed
FILES PegIntoSphereBed.cpp
DEPENDS blockforest mesh_common mesa_pd core vtk )
endif()
\ No newline at end of file
PegIntoSphereBed
{
simulationCorner < 0, 0, 0 >;
simulationDomain < 2, 2, 3 >;
blocks < 1, 1, 1 >;
isPeriodic < 0, 0, 0 >;
initialRefinementLevel 1;
shift < 0.01, 0.01, 0.01 >;
sphereBedHeight 1.5;
sphereRadius 0.1;
sphereSpacing 0.2;
sphereDensity 5000;
pegBodyHeight 3;
pegPikeHeight 1;
pegRadius 0.5;
pegNumSideEdges 20;
pegPikeTipPosition < 1, 1, 1.5 >;
pegVelocity < 0, 0, -0.05 >;
dt 0.0003;
simulationSteps 100000;
visSpacing 100;
}
This diff is collapsed.
......@@ -25,15 +25,18 @@ set ( WALBERLA_GLOB_FILES *.cpp
# [optional] This is done using the ${arg}_FOUND variable.
# Example: waLBerla_add_module( DEPENDS someModule BUILD_ONLY_IF_FOUND pe)
# This module is only built if PE_FOUND is true.
# OPTIONAL_DEPENDS Lists modules, that this module might depend on. For example a module could depend on mesh_common if OpenMesh is
# [optional] available.
#
#######################################################################################################################
function ( waLBerla_add_module )
set( options )
set( oneValueArgs )
set( multiValueArgs DEPENDS EXCLUDE FILES BUILD_ONLY_IF_FOUND )
set( multiValueArgs DEPENDS EXCLUDE FILES BUILD_ONLY_IF_FOUND OPTIONAL_DEPENDS )
cmake_parse_arguments( ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
set( ALL_DEPENDENCIES ${ARG_DEPENDS} ${ARG_OPTIONAL_DEPENDS})
# Module name is the directory relative to WALBERLA_MODULE_DIRS
get_current_module_name ( moduleName )
get_module_library_name ( moduleLibraryName ${moduleName} )
......@@ -76,7 +79,7 @@ function ( waLBerla_add_module )
endif ( )
# Dependency Check
check_dependencies( missingDeps additionalDeps FILES ${sourceFiles} EXPECTED_DEPS ${ARG_DEPENDS} ${moduleName} )
check_dependencies( missingDeps additionalDeps FILES ${sourceFiles} EXPECTED_DEPS ${ALL_DEPENDENCIES} ${moduleName} )
if ( missingDeps )
message ( WARNING "The module ${moduleName} depends on ${missingDeps} which are not listed as dependencies!" )
endif()
......
......@@ -16,7 +16,7 @@ if __name__ == '__main__':
mpd = Module(args.path)
ps = mpd.add(data.ParticleStorage())
ps.set_shapes('Sphere', 'HalfSpace', 'CylindricalBoundary', 'Box', 'Ellipsoid')
ps.set_shapes('Sphere', 'HalfSpace', 'CylindricalBoundary', 'Box', 'Ellipsoid', 'ConvexPolyhedron')
ps.add_property("position", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ALWAYS")
ps.add_property("linearVelocity", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ALWAYS")
ps.add_property("invMass", "walberla::real_t", defValue="real_t(1)", syncMode="ON_GHOST_CREATION")
......
......@@ -5,4 +5,11 @@
#
###################################################################################################
waLBerla_add_module( DEPENDS blockforest core stencil vtk )
waLBerla_add_module( DEPENDS blockforest core stencil vtk OPTIONAL_DEPENDS mesh_common )
if(OPENMESH_CORE_FOUND)
set( WALBERLA_MESAPD_CONVEX_POLYHEDRON_AVAILABLE ON CACHE INTERNAL "")
message( STATUS "MESA-PD: ConvexPolyhedron shape is available (OpenMesh dependency satisfied)" )
else()
set( WALBERLA_MESAPD_CONVEX_POLYHEDRON_AVAILABLE OFF CACHE INTERNAL "")
message( STATUS "MESA-PD: ConvexPolyhedron shape is unavailable (OpenMesh not found)" )
endif()
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -34,6 +34,7 @@
#include <mesa_pd/data/shape/CylindricalBoundary.h>
#include <mesa_pd/data/shape/Box.h>
#include <mesa_pd/data/shape/Ellipsoid.h>
#include <mesa_pd/data/shape/ConvexPolyhedron.h>
#include <core/Abort.h>
#include <core/debug/Debug.h>
......@@ -94,6 +95,11 @@ auto DoubleCast::operator()( size_t idx, size_t idy, Accessor& ac, func& f, Args
*static_cast<Sphere*>(ac.getShape(idx)),
*static_cast<Ellipsoid*>(ac.getShape(idy)),
std::forward<Args>(args)...);
case ConvexPolyhedron::SHAPE_TYPE : return f(idx,
idy,
*static_cast<Sphere*>(ac.getShape(idx)),
*static_cast<ConvexPolyhedron*>(ac.getShape(idy)),
std::forward<Args>(args)...);
default : WALBERLA_ABORT("Shape type (" << ac.getShape(idy)->getShapeType() << ") could not be determined!");
}
case HalfSpace::SHAPE_TYPE :
......@@ -124,6 +130,11 @@ auto DoubleCast::operator()( size_t idx, size_t idy, Accessor& ac, func& f, Args
*static_cast<HalfSpace*>(ac.getShape(idx)),
*static_cast<Ellipsoid*>(ac.getShape(idy)),
std::forward<Args>(args)...);
case ConvexPolyhedron::SHAPE_TYPE : return f(idx,
idy,
*static_cast<HalfSpace*>(ac.getShape(idx)),
*static_cast<ConvexPolyhedron*>(ac.getShape(idy)),
std::forward<Args>(args)...);
default : WALBERLA_ABORT("Shape type (" << ac.getShape(idy)->getShapeType() << ") could not be determined!");
}
case CylindricalBoundary::SHAPE_TYPE :
......@@ -154,6 +165,11 @@ auto DoubleCast::operator()( size_t idx, size_t idy, Accessor& ac, func& f, Args
*static_cast<CylindricalBoundary*>(ac.getShape(idx)),
*static_cast<Ellipsoid*>(ac.getShape(idy)),
std::forward<Args>(args)...);
case ConvexPolyhedron::SHAPE_TYPE : return f(idx,
idy,
*static_cast<CylindricalBoundary*>(ac.getShape(idx)),
*static_cast<ConvexPolyhedron*>(ac.getShape(idy)),
std::forward<Args>(args)...);
default : WALBERLA_ABORT("Shape type (" << ac.getShape(idy)->getShapeType() << ") could not be determined!");
}
case Box::SHAPE_TYPE :
......@@ -184,6 +200,11 @@ auto DoubleCast::operator()( size_t idx, size_t idy, Accessor& ac, func& f, Args
*static_cast<Box*>(ac.getShape(idx)),
*static_cast<Ellipsoid*>(ac.getShape(idy)),
std::forward<Args>(args)...);
case ConvexPolyhedron::SHAPE_TYPE : return f(idx,
idy,
*static_cast<Box*>(ac.getShape(idx)),
*static_cast<ConvexPolyhedron*>(ac.getShape(idy)),
std::forward<Args>(args)...);
default : WALBERLA_ABORT("Shape type (" << ac.getShape(idy)->getShapeType() << ") could not be determined!");
}
case Ellipsoid::SHAPE_TYPE :
......@@ -214,6 +235,46 @@ auto DoubleCast::operator()( size_t idx, size_t idy, Accessor& ac, func& f, Args
*static_cast<Ellipsoid*>(ac.getShape(idx)),
*static_cast<Ellipsoid*>(ac.getShape(idy)),
std::forward<Args>(args)...);
case ConvexPolyhedron::SHAPE_TYPE : return f(idx,
idy,
*static_cast<Ellipsoid*>(ac.getShape(idx)),
*static_cast<ConvexPolyhedron*>(ac.getShape(idy)),
std::forward<Args>(args)...);
default : WALBERLA_ABORT("Shape type (" << ac.getShape(idy)->getShapeType() << ") could not be determined!");
}
case ConvexPolyhedron::SHAPE_TYPE :
switch (ac.getShape(idy)->getShapeType())
{
case Sphere::SHAPE_TYPE : return f(idx,
idy,
*static_cast<ConvexPolyhedron*>(ac.getShape(idx)),
*static_cast<Sphere*>(ac.getShape(idy)),
std::forward<Args>(args)...);
case HalfSpace::SHAPE_TYPE : return f(idx,
idy,
*static_cast<ConvexPolyhedron*>(ac.getShape(idx)),
*static_cast<HalfSpace*>(ac.getShape(idy)),
std::forward<Args>(args)...);
case CylindricalBoundary::SHAPE_TYPE : return f(idx,
idy,
*static_cast<ConvexPolyhedron*>(ac.getShape(idx)),
*static_cast<CylindricalBoundary*>(ac.getShape(idy)),
std::forward<Args>(args)...);
case Box::SHAPE_TYPE : return f(idx,
idy,
*static_cast<ConvexPolyhedron*>(ac.getShape(idx)),
*static_cast<Box*>(ac.getShape(idy)),
std::forward<Args>(args)...);
case Ellipsoid::SHAPE_TYPE : return f(idx,
idy,
*static_cast<ConvexPolyhedron*>(ac.getShape(idx)),
*static_cast<Ellipsoid*>(ac.getShape(idy)),
std::forward<Args>(args)...);
case ConvexPolyhedron::SHAPE_TYPE : return f(idx,
idy,
*static_cast<ConvexPolyhedron*>(ac.getShape(idx)),
*static_cast<ConvexPolyhedron*>(ac.getShape(idy)),
std::forward<Args>(args)...);
default : WALBERLA_ABORT("Shape type (" << ac.getShape(idy)->getShapeType() << ") could not be determined!");
}
default : WALBERLA_ABORT("Shape type (" << ac.getShape(idx)->getShapeType() << ") could not be determined!");
......
......@@ -34,6 +34,7 @@
#include <mesa_pd/data/shape/CylindricalBoundary.h>
#include <mesa_pd/data/shape/Box.h>
#include <mesa_pd/data/shape/Ellipsoid.h>
#include <mesa_pd/data/shape/ConvexPolyhedron.h>
#include <core/Abort.h>
#include <core/debug/Debug.h>
......@@ -70,6 +71,7 @@ auto SingleCast::operator()( size_t idx, Accessor& ac, func& f, Args&&... args )
case CylindricalBoundary::SHAPE_TYPE : return f(idx, *static_cast<CylindricalBoundary*>(ac.getShape(idx)), std::forward<Args>(args)...);
case Box::SHAPE_TYPE : return f(idx, *static_cast<Box*>(ac.getShape(idx)), std::forward<Args>(args)...);
case Ellipsoid::SHAPE_TYPE : return f(idx, *static_cast<Ellipsoid*>(ac.getShape(idx)), std::forward<Args>(args)...);
case ConvexPolyhedron::SHAPE_TYPE : return f(idx, *static_cast<ConvexPolyhedron*>(ac.getShape(idx)), std::forward<Args>(args)...);
default : WALBERLA_ABORT("Shape type (" << ac.getShape(idx)->getShapeType() << ") could not be determined!");
}
}
......
......@@ -32,6 +32,7 @@
#include <mesa_pd/data/shape/CylindricalBoundary.h>
#include <mesa_pd/data/shape/Box.h>
#include <mesa_pd/data/shape/Ellipsoid.h>
#include <mesa_pd/data/shape/ConvexPolyhedron.h>
#include <core/mpi/RecvBuffer.h>
#include <core/mpi/SendBuffer.h>
......@@ -83,6 +84,10 @@ namespace mpi {
bs = std::make_unique<mesa_pd::data::Ellipsoid>();
bs->unpack(buf);
break;
case ConvexPolyhedron::SHAPE_TYPE :
bs = std::make_unique<mesa_pd::data::ConvexPolyhedron>();
bs->unpack(buf);
break;
default : WALBERLA_ABORT("Shape type (" << shapeType << ") could not be determined!");
}
return buf;
......
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file MeshVTKOutput.h
//! \author Lukas Werner
//
//======================================================================================================================
#pragma once
#include <OpenMesh/Core/Utils/PropertyManager.hh>
#include <mesa_pd/data/ParticleStorage.h>
#include <mesa_pd/data/ShapeStorage.h>
#include <mesa_pd/data/shape/ConvexPolyhedron.h>
#include <mesa_pd/vtk/ConvexPolyhedron/Types.h>
#include <mesa_pd/vtk/ConvexPolyhedron/data_sources/DataSourceAdapters.h>
#include <mesa_pd/vtk/ConvexPolyhedron/data_sources/FaceDataSource.h>
#include <mesa_pd/vtk/ConvexPolyhedron/data_sources/OutputSelectorFaceDataSource.h>
#include <mesa_pd/vtk/ConvexPolyhedron/data_sources/OutputSelectorVertexDataSource.h>
#include <mesa_pd/vtk/ConvexPolyhedron/data_sources/VertexDataSource.h>
#include <mesa_pd/vtk/ConvexPolyhedron/tesselation/ConvexPolyhedronTesselation.h>
#include <mesh_common/vtk/DistributedVTKMeshWriter.h>
#include <utility>
namespace walberla {
namespace mesa_pd {
template<typename MeshType>
class MeshParticleVTKOutput {
static_assert(MeshType::IsPolyMesh == 1, "We need polygonal meshes here!");
public:
using ParticleSelectorFunc = std::function<bool (const walberla::mesa_pd::data::ParticleStorage::iterator& pIt)>;
typedef typename mesh::DistributedVTKMeshWriter<MeshType>::Vertices Vertices;
MeshParticleVTKOutput( shared_ptr<walberla::mesa_pd::data::ParticleStorage> ps,
shared_ptr<walberla::mesa_pd::data::ShapeStorage> ss, const std::string & identifier,
const uint_t writeFrequency, const std::string & baseFolder = "vtk_out")
: ps_(std::move(ps)), ss_(std::move(ss)), mesh_(make_shared<MeshType>()),
faceToParticleIdxManager_(*mesh_, "particle"), vertexToParticleIdxManager_(*mesh_, "particle"),
meshWriter_(mesh_, identifier, writeFrequency, baseFolder) {
}
void setParticleSelector( const ParticleSelectorFunc& func) {particleSelector_ = func;}
void assembleMesh();
template <typename Selector>
void addVertexOutput(const std::string& name);
template<typename Selector>
void addFaceOutput(const std::string &name);
template <typename DataSourceType>
void addVertexDataSource(const shared_ptr<DataSourceType> & dataSource);
template <typename DataSourceType>
void addFaceDataSource(const shared_ptr<DataSourceType> & dataSource);
void operator()() {
assembleMesh();
// the mesh writer writes the mesh to vtk files and adds properties as defined by the data sources
meshWriter_();
mesh_->clean(); // the output mesh is no longer needed, thus discard its contents
}
private:
const shared_ptr<walberla::mesa_pd::data::ParticleStorage> ps_;
const shared_ptr<walberla::mesa_pd::data::ShapeStorage> ss_;
shared_ptr<MeshType> mesh_; ///< the output mesh
// these "managers" (which are just maps basically) map the faces and vertices of the output mesh to particles
// such that we can assign those faces and vertices properties of the particle (i.e. ID or velocity)
ParticleIdxFacePropertyManager<MeshType> faceToParticleIdxManager_;
ParticleIdxVertexPropertyManager<MeshType> vertexToParticleIdxManager_;
mesh::DistributedVTKMeshWriter<MeshType> meshWriter_;
ParticleSelectorFunc particleSelector_ = [](const walberla::mesa_pd::data::ParticleStorage::iterator& /*pIt*/){
return true;
};
};
/**
* \brief Adds a output selector for the vertices of the mesh
* Similar to MESAPD's vtk output, one can add a property selector to select a property for a vertex
* corresponding to the associated particle.
*
* \tparam MeshType
* \tparam Selector Type of the selector
* \param name Name of the output
*/
template<typename MeshType>
template<typename Selector>
void MeshParticleVTKOutput<MeshType>::addVertexOutput(const std::string &name) {
typedef OutputSelectorVertexDataSource<MeshType, Selector, typename Selector::return_type> DataSourceType;
auto ds = make_shared<DataSourceType>(name, Selector());
addVertexDataSource(ds);
}
/**
* \brief Adds a output selector for the faces of the mesh
* Similar to MESAPD's vtk output, one can add a property selector to select a property for a face
* corresponding to the associated particle.
*
* \tparam MeshType
* \tparam Selector Type of the selector
* \param name Name of the output
*/
template<typename MeshType>
template<typename Selector>
void MeshParticleVTKOutput<MeshType>::addFaceOutput(const std::string &name) {
typedef OutputSelectorFaceDataSource<MeshType, Selector, typename Selector::return_type> DataSourceType;
auto ds = make_shared<DataSourceType>(name, Selector());
addFaceDataSource(ds);
}
/**
* \brief Add a vertex data source assigning a piece of data to a vertex.
* \tparam MeshType
* \tparam DataSourceType Type of data source (has to be derived from VertexDataSource).
* \param dataSource Data source responsible for picking data for a vertex.
*/
template<typename MeshType>
template<typename DataSourceType>
void MeshParticleVTKOutput<MeshType>::addVertexDataSource(const shared_ptr<DataSourceType> & dataSource) {
typedef internal::VertexDataSourceAdapter<MeshType, typename DataSourceType::ComponentType> AdapterType;
meshWriter_.addDataSource(make_shared<AdapterType>(dataSource, vertexToParticleIdxManager_, ps_));
}
/**
* \brief Add a face data source assigning a piece of data to a face.
* \tparam MeshType
* \tparam DataSourceType Type of data source (has to be derived from FaceDataSource).
* \param dataSource Data source responsible for picking data for a face.
*/
template<typename MeshType>
template<typename DataSourceType>
void MeshParticleVTKOutput<MeshType>::addFaceDataSource(const shared_ptr<DataSourceType> & dataSource) {
typedef internal::FaceDataSourceAdapter<MeshType, typename DataSourceType::ComponentType> AdapterType;
meshWriter_.addDataSource(make_shared<AdapterType>(dataSource, faceToParticleIdxManager_, ps_));
}
/**
* \brief Creates the output mesh and writes it to mesh_.
* \tparam MeshType
*/
template<typename MeshType>
void MeshParticleVTKOutput<MeshType>::assembleMesh() {
// those will save the newly created vertices and faces for each mesh
// to make it possible to map a vertex/face to the corresponding particle
std::vector<typename MeshType::VertexHandle> newVertices;
std::vector<typename MeshType::FaceHandle> newFaces;
// ensure the mesh is empty, as this will contain the new output
mesh_->clean();
// then iterate over every particle and tesselate it to include it in the output mesh
for (auto pIt = ps_->begin(); pIt != ps_->end(); ++pIt) {
if (!particleSelector_(pIt)) continue;
auto& shape = ss_->shapes[pIt->getShapeID()];
newVertices.clear();
newFaces.clear();
if (shape->getShapeType() == walberla::mesa_pd::data::ConvexPolyhedron::SHAPE_TYPE) {
const auto& convexPolyhedron = *static_cast<walberla::mesa_pd::data::ConvexPolyhedron*>(shape.get());
const auto& particle = *pIt;
// tesselate: add the shape at the particle's position into the output mesh
tesselate(convexPolyhedron, particle, mesh_, newVertices, newFaces);
}
// save particle idx to managers
for (const auto & vertex: newVertices) {
vertexToParticleIdxManager_[vertex] = pIt->getIdx();
}
for (const auto & face: newFaces) {
faceToParticleIdxManager_[face] = pIt->getIdx();
}
}
//WALBERLA_LOG_INFO("MESA-PD VTK output mesh contains " << mesh_->n_vertices() << " vertices.")
}
}
}
\ No newline at end of file
#include <OpenMesh/Core/Utils/Property.hh>
#include <OpenMesh/Core/Utils/PropertyManager.hh>
namespace walberla {
namespace mesa_pd {
typedef typename OpenMesh::FPropHandleT<size_t> ParticleIdxFacePropertyHandle;
typedef typename OpenMesh::VPropHandleT<size_t> ParticleIdxVertexPropertyHandle;
template <typename MeshType>
using ParticleIdxFacePropertyManager = OpenMesh::PropertyManager<ParticleIdxFacePropertyHandle, MeshType>;
template <typename MeshType>
using ParticleIdxVertexPropertyManager = typename OpenMesh::PropertyManager<ParticleIdxVertexPropertyHandle, MeshType>;
}
}
\ No newline at end of file
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file DataSourceAdapters.h
//! \author Lukas Werner
//
//======================================================================================================================
#pragma once
#include <core/DataTypes.h>
#include <mesa_pd/vtk/ConvexPolyhedron/data_sources/FaceDataSource.h>
#include <mesa_pd/vtk/ConvexPolyhedron/data_sources/VertexDataSource.h>
#include <mesh_common/vtk/DistributedVTKMeshWriter.h>
namespace walberla {
namespace mesa_pd {
namespace internal {
/**
* \brief Adapts a vertex data source for the MESAPD mesh output to the generic vertex data source class.
* \tparam MeshType
* \tparam T output type
*/
template<typename MeshType, typename T >
class VertexDataSourceAdapter : public mesh::DistributedVTKMeshWriter<MeshType>::template VertexDataSource<T> {
public:
typedef typename mesh::DistributedVTKMeshWriter<MeshType>::template VertexDataSource<T>::Vertices Vertices;
VertexDataSourceAdapter( const shared_ptr<VertexDataSource<MeshType, T>> & vertexDataSource,
const ParticleIdxVertexPropertyManager<MeshType> & vertexToParticleIdxManager,
const shared_ptr<walberla::mesa_pd::data::ParticleStorage> & ps)
: mesh::DistributedVTKMeshWriter<MeshType>::template VertexDataSource<T>( vertexDataSource->name() ),
vertexDataSource_(vertexDataSource), vertexToParticleIdxManager_(vertexToParticleIdxManager),
ps_(ps) { }
virtual void getData(const MeshType & mesh, const Vertices & vertices, std::vector<T> & data) {
return vertexDataSource_->getData( mesh, vertices, data, vertexToParticleIdxManager_, ps_ );
};
virtual uint_t numComponents() { return vertexDataSource_->numComponents(); }
protected:
shared_ptr<VertexDataSource<MeshType, T>> vertexDataSource_;