Commit 2eeee982 authored by Martin Bauer's avatar Martin Bauer

Merge remote-tracking branch 'origin/master' into gpu

parents 44a42d08 b234daf1
Pipeline #16464 passed with stages
in 346 minutes and 3 seconds
......@@ -745,6 +745,97 @@ gcc_8_mpionly:
gcc_8_hybrid:
<<: *build_definition
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
variables:
<<: *build_hybrid_variables
WALBERLA_BUILD_WITH_CUDA: "OFF"
WALBERLA_ENABLE_GUI: 0
only:
variables:
- $ENABLE_NIGHTLY_BUILDS
tags:
- docker
gcc_8_serial_dbg:
<<: *build_definition
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
variables:
<<: *build_serial_dbg_variables
WALBERLA_BUILD_WITH_CUDA: "OFF"
WALBERLA_ENABLE_GUI: 0
only:
variables:
- $ENABLE_NIGHTLY_BUILDS
tags:
- docker
gcc_8_mpionly_dbg:
<<: *build_definition
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
variables:
<<: *build_mpionly_dbg_variables
WALBERLA_BUILD_WITH_CUDA: "OFF"
WALBERLA_ENABLE_GUI: 0
only:
variables:
- $ENABLE_NIGHTLY_BUILDS
tags:
- docker
gcc_8_hybrid_dbg:
<<: *build_definition
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
variables:
<<: *build_hybrid_dbg_variables
WALBERLA_BUILD_WITH_CUDA: "OFF"
WALBERLA_ENABLE_GUI: 0
only:
variables:
- $ENABLE_NIGHTLY_BUILDS
tags:
- docker
gcc_8_hybrid_dbg_sp:
<<: *build_definition
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
variables:
<<: *build_hybrid_dbg_sp_variables
WALBERLA_BUILD_WITH_CUDA: "OFF"
WALBERLA_ENABLE_GUI: 0
only:
variables:
- $ENABLE_NIGHTLY_BUILDS
tags:
- docker
gcc_9_serial:
<<: *build_definition
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
variables:
<<: *build_serial_variables
WALBERLA_BUILD_WITH_CUDA: "OFF"
WALBERLA_ENABLE_GUI: 0
only:
variables:
- $ENABLE_NIGHTLY_BUILDS
tags:
- docker
gcc_9_mpionly:
<<: *build_definition
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
variables:
<<: *build_mpionly_variables
WALBERLA_BUILD_WITH_CUDA: "OFF"
WALBERLA_ENABLE_GUI: 0
only:
variables:
- $ENABLE_NIGHTLY_BUILDS
tags:
- docker
gcc_9_hybrid:
<<: *build_definition
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
stage: pretest
variables:
<<: *build_hybrid_variables
......@@ -756,9 +847,9 @@ gcc_8_hybrid:
tags:
- docker
gcc_8_serial_dbg:
gcc_9_serial_dbg:
<<: *build_definition
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
variables:
<<: *build_serial_dbg_variables
WALBERLA_BUILD_WITH_CUDA: "OFF"
......@@ -769,9 +860,9 @@ gcc_8_serial_dbg:
tags:
- docker
gcc_8_mpionly_dbg:
gcc_9_mpionly_dbg:
<<: *build_definition
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
variables:
<<: *build_mpionly_dbg_variables
WALBERLA_BUILD_WITH_CUDA: "OFF"
......@@ -782,9 +873,9 @@ gcc_8_mpionly_dbg:
tags:
- docker
gcc_8_hybrid_dbg:
gcc_9_hybrid_dbg:
<<: *build_definition
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
variables:
<<: *build_hybrid_dbg_variables
WALBERLA_BUILD_WITH_CUDA: "OFF"
......@@ -795,9 +886,9 @@ gcc_8_hybrid_dbg:
tags:
- docker
gcc_8_hybrid_dbg_sp:
gcc_9_hybrid_dbg_sp:
<<: *build_definition
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:8
image: i10git.cs.fau.de:5005/walberla/buildenvs/gcc:9
variables:
<<: *build_hybrid_dbg_sp_variables
WALBERLA_BUILD_WITH_CUDA: "OFF"
......@@ -1786,4 +1877,4 @@ benchmark_gcc8:
benchmark_clang8:
<<: *benchmark_definition
image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:8.0
image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:8.0
\ No newline at end of file
......@@ -57,6 +57,7 @@
#include "mesh/TriangleMeshes.h"
#include "mesh/MeshOperations.h"
#include "mesh/DistanceComputations.h"
#include "mesh/DistanceFunction.h"
#include "mesh/MeshIO.h"
#include "mesh/MatrixVectorOperations.h"
#include "mesh/blockforest/BlockForestInitialization.h"
......@@ -67,6 +68,7 @@
#include "mesh/boundary/BoundarySetup.h"
#include "mesh/boundary/BoundaryInfo.h"
#include "mesh/boundary/BoundaryLocation.h"
#include "mesh/boundary/BoundaryLocationFunction.h"
#include "mesh/boundary/BoundaryUIDFaceDataSource.h"
#include "mesh/boundary/ColorToBoundaryMapper.h"
#include "mesh/vtk/VTKMeshWriter.h"
......@@ -84,47 +86,6 @@
namespace walberla {
template< typename MeshDistanceType >
struct MeshDistanceFunction
{
MeshDistanceFunction( const shared_ptr< MeshDistanceType > & meshDistanceObject ) : meshDistanceObject_( meshDistanceObject ) { }
inline real_t operator()( const Vector3< real_t > & p ) const { return real_c( meshDistanceObject_->sqSignedDistance( mesh::toOpenMesh( p ) ) ); }
shared_ptr< MeshDistanceType > meshDistanceObject_;
};
template< typename MeshDistanceType >
inline MeshDistanceFunction< MeshDistanceType > makeMeshDistanceFunction( const shared_ptr< MeshDistanceType > & meshDistanceObject )
{
return MeshDistanceFunction< MeshDistanceType >( meshDistanceObject );
}
template< typename MeshDistanceType, typename MeshType >
struct BoundaryLocationFunction
{
BoundaryLocationFunction( const shared_ptr< MeshDistanceType > & meshDistanceObject, const shared_ptr< mesh::BoundaryLocation< MeshType > > & boundaryLocation )
: meshDistanceObject_( meshDistanceObject ), boundaryLocation_( boundaryLocation ) { }
inline const mesh::BoundaryInfo & operator()( const Vector3< real_t > & p ) const
{
typename MeshType::FaceHandle fh;
meshDistanceObject_->sqSignedDistance( mesh::toOpenMesh( p ), fh );
return (*boundaryLocation_)[ fh ];
}
shared_ptr< MeshDistanceType > meshDistanceObject_;
shared_ptr< mesh::BoundaryLocation< MeshType > > boundaryLocation_;
};
template< typename MeshDistanceType, typename MeshType >
inline BoundaryLocationFunction< MeshDistanceType, MeshType > makeBoundaryLocationFunction( const shared_ptr< MeshDistanceType > & meshDistanceObject, const shared_ptr< mesh::BoundaryLocation< MeshType > > & boundaryLocation )
{
return BoundaryLocationFunction< MeshDistanceType, MeshType >( meshDistanceObject, boundaryLocation );
}
template< typename MeshType >
void vertexToFaceColor( MeshType & mesh, const typename MeshType::Color & defaultColor )
{
......
......@@ -74,19 +74,15 @@ class ParticleAccessorWithShape : public data::ParticleAccessor
{
public:
ParticleAccessorWithShape(std::shared_ptr<data::ParticleStorage>& ps, std::shared_ptr<data::ShapeStorage>& ss)
: ParticleAccessor(ps)
, ss_(ss)
: ParticleAccessor(ps)
, ss_(ss)
{}
const walberla::real_t& getInvMass(const size_t p_idx) const {return ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvMass();}
walberla::real_t& getInvMassRef(const size_t p_idx) {return ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvMass();}
void setInvMass(const size_t p_idx, const walberla::real_t& v) { ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvMass() = v;}
const auto& getInvMass(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvMass();}
const auto& getInvInertiaBF(const size_t p_idx) const {return ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvInertiaBF();}
auto& getInvInertiaBFRef(const size_t p_idx) {return ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvInertiaBF();}
void setInvInertiaBF(const size_t p_idx, const Mat3& v) { ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvInertiaBF() = v;}
const auto& getInvInertiaBF(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvInertiaBF();}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeIDRef(p_idx)].get();}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)].get();}
private:
std::shared_ptr<data::ShapeStorage> ss_;
};
......
......@@ -99,19 +99,15 @@ class ParticleAccessorWithShape : public data::ParticleAccessor
{
public:
ParticleAccessorWithShape(std::shared_ptr<data::ParticleStorage>& ps, std::shared_ptr<data::ShapeStorage>& ss)
: ParticleAccessor(ps)
, ss_(ss)
: ParticleAccessor(ps)
, ss_(ss)
{}
const walberla::real_t& getInvMass(const size_t p_idx) const {return ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvMass();}
walberla::real_t& getInvMassRef(const size_t p_idx) {return ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvMass();}
void setInvMass(const size_t p_idx, const walberla::real_t& v) { ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvMass() = v;}
const auto& getInvMass(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvMass();}
const auto& getInvInertiaBF(const size_t p_idx) const {return ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvInertiaBF();}
auto& getInvInertiaBFRef(const size_t p_idx) {return ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvInertiaBF();}
void setInvInertiaBF(const size_t p_idx, const Mat3& v) { ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvInertiaBF() = v;}
const auto& getInvInertiaBF(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvInertiaBF();}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeIDRef(p_idx)].get();}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)].get();}
private:
std::shared_ptr<data::ShapeStorage> ss_;
};
......
......@@ -33,6 +33,7 @@ if __name__ == '__main__':
ch = data.ContactHistory()
lc = data.LinkedCells()
ss = data.ShapeStorage(ps, shapes)
cs = data.ContactStorage()
ps.addProperty("position", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ALWAYS")
ps.addProperty("linearVelocity", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ALWAYS")
......@@ -54,14 +55,37 @@ if __name__ == '__main__':
ps.addProperty("oldContactHistory", "std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>", defValue="", syncMode="ALWAYS")
ps.addProperty("newContactHistory", "std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>", defValue="", syncMode="NEVER")
ps.addProperty("temperature", "walberla::real_t", defValue="real_t(0)", syncMode="ALWAYS")
ps.addProperty("heatFlux", "walberla::real_t", defValue="real_t(0)", syncMode="NEVER")
ps.addProperty("temperature", "walberla::real_t", defValue="real_t(0)", syncMode="ALWAYS")
ps.addProperty("heatFlux", "walberla::real_t", defValue="real_t(0)", syncMode="NEVER")
# Properties for HCSITS
ps.addProperty("dv", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="NEVER")
ps.addProperty("dw", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="NEVER")
ch.addProperty("tangentialSpringDisplacement", "walberla::mesa_pd::Vec3", defValue="real_t(0)")
ch.addProperty("isSticking", "bool", defValue="false")
ch.addProperty("impactVelocityMagnitude", "real_t", defValue="real_t(0)")
cs.addProperty("id1", "walberla::id_t", defValue = "walberla::id_t(-1)", syncMode="NEVER")
cs.addProperty("id2", "walberla::id_t", defValue = "walberla::id_t(-1)", syncMode="NEVER")
cs.addProperty("distance", "real_t", defValue = "real_t(1)", syncMode="NEVER")
cs.addProperty("normal", "walberla::mesa_pd::Vec3", defValue = "real_t(0)", syncMode="NEVER")
cs.addProperty("position", "walberla::mesa_pd::Vec3", defValue = "real_t(0)", syncMode="NEVER")
cs.addProperty("t", "walberla::mesa_pd::Vec3", defValue = "real_t(0)", syncMode="NEVER")
cs.addProperty("o", "walberla::mesa_pd::Vec3", defValue = "real_t(0)", syncMode="NEVER")
cs.addProperty("r1", "walberla::mesa_pd::Vec3", defValue = "real_t(0)", syncMode="NEVER")
cs.addProperty("r2", "walberla::mesa_pd::Vec3", defValue = "real_t(0)", syncMode="NEVER")
cs.addProperty("mu", "real_t", defValue = "real_t(0)", syncMode="NEVER")
cs.addProperty("p", "walberla::mesa_pd::Vec3", defValue = "real_t(0)", syncMode="NEVER")
cs.addProperty("diag_nto", "walberla::mesa_pd::Mat3", defValue = "real_t(0)", syncMode="NEVER")
cs.addProperty("diag_nto_inv", "walberla::mesa_pd::Mat3", defValue = "real_t(0)", syncMode="NEVER")
cs.addProperty("diag_to_inv", "walberla::mesa_pd::Mat2", defValue = "real_t(0)", syncMode="NEVER")
cs.addProperty("diag_n_inv", "real_t", defValue = "real_t(0)", syncMode="NEVER")
cs.addProperty("p", "walberla::mesa_pd::Vec3", defValue = "real_t(0)", syncMode="NEVER")
kernels = []
kernels.append( kernel.DetectAndStoreContacts() )
kernels.append( kernel.DoubleCast(shapes) )
kernels.append( kernel.ExplicitEuler() )
kernels.append( kernel.ExplicitEulerWithShape() )
......@@ -76,6 +100,7 @@ if __name__ == '__main__':
kernels.append( kernel.VelocityVerlet() )
kernels.append( kernel.VelocityVerletWithShape() )
ac = Accessor()
for k in kernels:
ac.mergeRequirements(k.getRequirements())
......@@ -86,6 +111,7 @@ if __name__ == '__main__':
comm.append(mpi.ClearNextNeighborSync())
comm.append(mpi.ReduceContactHistory())
comm.append(mpi.ReduceProperty())
comm.append(mpi.SyncGhostOwners(ps))
comm.append(mpi.SyncNextNeighbors(ps))
......@@ -93,6 +119,7 @@ if __name__ == '__main__':
ch.generate(args.path + "/src/mesa_pd/")
lc.generate(args.path + "/src/mesa_pd/")
ss.generate(args.path + "/src/mesa_pd/")
cs.generate(args.path + "/src/mesa_pd/")
for k in kernels:
k.generate(args.path + "/src/mesa_pd/")
......
# -*- coding: utf-8 -*-
import numpy as np
from ..Container import Container
from ..utility import generateFile
class ContactStorage(Container):
def __init__(self):
super().__init__()
self.addProperty("uid", "walberla::id_t", defValue = "walberla::id_t(-1)", syncMode="NEVER")
def generate(self, path):
self.unrollDimension()
print("="*90)
print("Creating ContactStorage Datastructure:")
print("")
print("{0: <20}{1: <30}{2: <20}{3: <10}".format("Type", "Name", "Def. Value", "SyncMode"))
print("="*90)
for prop in self.properties:
print("{0: <20.19}{1: <30.29}{2: <20.19}{3: <10.9}".format(prop.type, prop.name, prop.defValue, prop.syncMode))
print("="*90)
context = dict()
context["includes"] = self.includes
context["properties"] = self.properties
generateFile(path, 'data/ContactStorage.templ.h', context, filename='data/ContactStorage.h')
generateFile(path, 'data/ContactAccessor.templ.h', context, filename='data/ContactAccessor.h')
......@@ -10,12 +10,12 @@ class ParticleStorage(Container):
self.addInclude("mesa_pd/data/Flags.h")
self.addProperty("uid", "walberla::id_t", defValue = "UniqueID<data::Particle>::invalidID()", syncMode="ALWAYS")
self.addProperty("uid", "walberla::id_t", defValue = "UniqueID<data::Particle>::invalidID()", syncMode="ALWAYS")
self.addProperty("position", "walberla::mesa_pd::Vec3", defValue = "real_t(0)", syncMode="ALWAYS")
self.addProperty("interactionRadius", "walberla::real_t", defValue = "real_t(0)", syncMode="COPY")
self.addProperty("interactionRadius", "walberla::real_t", defValue = "real_t(0)", syncMode="COPY")
self.addProperty("flags", "walberla::mesa_pd::data::particle_flags::FlagT", defValue = "", syncMode="COPY")
self.addProperty("owner", "int", defValue = "-1", syncMode="COPY")
self.addProperty("ghostOwners", "std::vector<int>", defValue = "", syncMode="MIGRATION")
self.addProperty("owner", "int", defValue = "-1", syncMode="COPY")
self.addProperty("ghostOwners", "std::unordered_set<walberla::mpi::MPIRank>", defValue = "", syncMode="MIGRATION")
def generate(self, path):
self.unrollDimension()
......@@ -40,7 +40,9 @@ class ParticleStorage(Container):
generateFile(path, 'mpi/notifications/HeatFluxNotification.templ.h', context)
generateFile(path, 'mpi/notifications/ParseMessage.templ.h', context)
generateFile(path, 'mpi/notifications/ParticleCopyNotification.templ.h', context)
generateFile(path, 'mpi/notifications/NewGhostParticleNotification.templ.h', context)
generateFile(path, 'mpi/notifications/ParticleMigrationNotification.templ.h', context)
generateFile(path, 'mpi/notifications/ParticleRemoteMigrationNotification.templ.h', context)
generateFile(path, 'mpi/notifications/ParticleRemovalInformationNotification.templ.h', context)
generateFile(path, 'mpi/notifications/ParticleRemovalNotification.templ.h', context)
generateFile(path, 'mpi/notifications/ParticleUpdateNotification.templ.h', context)
# -*- coding: utf-8 -*-
from .ContactHistory import ContactHistory
from .ContactStorage import ContactStorage
from .LinkedCells import LinkedCells
from .ParticleStorage import ParticleStorage
from .ShapeStorage import ShapeStorage
__all__ = ['ContactHistory',
'ContactStorage',
'GeometryStorage',
'LinkedCells',
'ParticleStorage']
# -*- coding: utf-8 -*-
from mesa_pd.accessor import Accessor
from mesa_pd.utility import generateFile
class DetectAndStoreContacts:
def __init__(self):
self.accessor = Accessor()
self.accessor.require("uid", "walberla::id_t", access="g")
self.accessor.require("flags", "walberla::mesa_pd::data::particle_flags::FlagT", access="g")
self.accessor.require("position", "walberla::mesa_pd::Vec3", access="g")
self.accessor.require("rotation", "walberla::mesa_pd::Rot3", access="g")
self.accessor.require("shape", "BaseShape*", access="g")
def getRequirements(self):
return self.accessor
def generate(self, path):
context = dict()
context["interface"] = self.accessor.properties
generateFile(path, 'kernel/DetectAndStoreContacts.templ.h', context)
# -*- coding: utf-8 -*-
from .DetectAndStoreContacts import DetectAndStoreContacts
from .DoubleCast import DoubleCast
from .ExplicitEuler import ExplicitEuler
from .ExplicitEulerWithShape import ExplicitEulerWithShape
......@@ -15,6 +15,7 @@ from .VelocityVerlet import VelocityVerlet
from .VelocityVerletWithShape import VelocityVerletWithShape
__all__ = ['DoubleCast',
'DetectAndStoreContacts',
'ExplicitEuler',
'ExplicitEulerWithShape',
'ForceLJ',
......
# -*- coding: utf-8 -*-
from ..utility import generateFile
class SyncGhostOwners:
def __init__(self, p):
p.addProperty("position", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ALWAYS")
p.addProperty("interactionRadius", "walberla::real_t", defValue="real_t(0)", syncMode="ONCE")
p.addProperty("flags", "walberla::mesa_pd::data::particle_flags::FlagT", defValue="", syncMode="ONCE")
p.addProperty("owner", "int", defValue="-1", syncMode="ONCE")
p.addProperty("ghostOwners", "std::unordered_set<walberla::mpi::MPIRank>", defValue="", syncMode="NEVER")
p.addProperty("neighborState", "std::unordered_set<walberla::mpi::MPIRank>", defValue="", syncMode="NEVER")
def generate(self, path):
generateFile(path, 'mpi/SyncGhostOwners.templ.h')
generateFile(path, 'mpi/SyncGhostOwners.templ.cpp')
......@@ -5,10 +5,10 @@ from ..utility import generateFile
class SyncNextNeighbors:
def __init__(self, p):
p.addProperty("position", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="ALWAYS")
p.addProperty("interactionRadius", "walberla::real_t", defValue="real_t(0)", syncMode="ONCE")
p.addProperty("interactionRadius", "walberla::real_t", defValue="real_t(0)", syncMode="ONCE")
p.addProperty("flags", "walberla::mesa_pd::data::particle_flags::FlagT", defValue="", syncMode="ONCE")
p.addProperty("owner", "int", defValue="-1", syncMode="ONCE")
p.addProperty("ghostOwners", "std::vector<int>", defValue="", syncMode="NEVER")
p.addProperty("owner", "int", defValue="-1", syncMode="ONCE")
p.addProperty("ghostOwners", "std::unordered_set<walberla::mpi::MPIRank>", defValue="", syncMode="NEVER")
def generate(self, path):
generateFile(path, 'mpi/SyncNextNeighbors.templ.h')
......
......@@ -4,11 +4,13 @@ from .BroadcastProperty import BroadcastProperty
from .ClearNextNeighborSync import ClearNextNeighborSync
from .ReduceContactHistory import ReduceContactHistory
from .ReduceProperty import ReduceProperty
from .SyncGhostOwners import SyncGhostOwners
from .SyncNextNeighbors import SyncNextNeighbors
__all__ = ['BroadcastProperty',
'ClearNextNeighborSync',
'ReduceContactHistory',
'ReduceProperty',
'SyncGhostOwners',
'SyncNextNeighbors',
]
//======================================================================================================================
//
// 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 ContactAccessor.h
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
//======================================================================================================================
//
// THIS FILE IS GENERATED - PLEASE CHANGE THE TEMPLATE !!!
//
//======================================================================================================================
#pragma once
#include <mesa_pd/data/IAccessor.h>
#include <mesa_pd/data/ContactStorage.h>
#include <core/UniqueID.h>
#include <limits>
namespace walberla {
namespace mesa_pd {
namespace data {
/**
* @brief Basic ContactAccessor for the ContactStorage
*
* Provides get, set and getRef for all members of the ContactStorage.
* Can be used as a basis class for a more advanced ContactAccessor.
*/
class ContactAccessor : public IAccessor
{
public:
ContactAccessor(const std::shared_ptr<data::ContactStorage>& ps) : ps_(ps) {}
virtual ~ContactAccessor() = default;
{%- for prop in properties %}
const {{prop.type}}& get{{prop.name | capFirst}}(const size_t p_idx) const {return ps_->get{{prop.name | capFirst}}(p_idx);}
{{prop.type}}& get{{prop.name | capFirst}}Ref(const size_t p_idx) {return ps_->get{{prop.name | capFirst}}Ref(p_idx);}
void set{{prop.name | capFirst}}(const size_t p_idx, const {{prop.type}}& v) { ps_->set{{prop.name | capFirst}}(p_idx, v);}
{% endfor %}
id_t getInvalidUid() const {return UniqueID<data::Contact>::invalidID();}
size_t getInvalidIdx() const {return std::numeric_limits<size_t>::max();}
/**
* @brief Returns the index of Contact specified by uid.
* @param uid unique id of the Contact to be looked up
* @return the index of the Contact or std::numeric_limits<size_t>::max() if the Contact is not found
*/
size_t uidToIdx(const id_t& uid) const {auto it = ps_->find(uid); return it != ps_->end() ? it.getIdx() : std::numeric_limits<size_t>::max();}
size_t size() const { return ps_->size(); }
inline size_t create(const id_t& uid);
inline size_t erase(const size_t& idx);
inline size_t find(const id_t& uid);
protected:
std::shared_ptr<data::ContactStorage> ps_;
};
inline size_t ContactAccessor::create(const id_t& uid)
{
auto it = ps_->create(uid);
return it.getIdx();
}
inline size_t ContactAccessor::erase(const size_t& idx)
{
data::ContactStorage::iterator it(ps_.get(), idx);
it = ps_->erase(it);
return it.getIdx();
}
inline size_t ContactAccessor::find(const id_t& uid)
{
auto it = ps_->find(uid);
return it.getIdx();
}
/**
* @brief Basic ContactAccessor which emulates a single Contact in a ContactStorage
* without actually needing a ContactStorage. This class is used mainly for testing purposes.
*
* Provides get, set and getRef.
*/
class SingleContactAccessor : public IAccessor
{
public:
virtual ~SingleContactAccessor() = default;
{%- for prop in properties %}
const {{prop.type}}& get{{prop.name | capFirst}}(const size_t /*p_idx*/) const {return {{prop.name}}_;}
void set{{prop.name | capFirst}}(const size_t /*p_idx*/, const {{prop.type}}& v) { {{prop.name}}_ = v;}
{{prop.type}}& get{{prop.name | capFirst}}Ref(const size_t /*p_idx*/) {return {{prop.name}}_;}
{% endfor %}
id_t getInvalidUid() const {return UniqueID<data::Contact>::invalidID();}
size_t getInvalidIdx() const {return std::numeric_limits<size_t>::max();}
/**
* @brief Returns the index of Contact specified by uid.
* @param uid unique id of the Contact to be looked up
* @return the index of the Contact or std::numeric_limits<size_t>::max() if the Contact is not found
*/
size_t uidToIdx(const id_t& uid) const {return uid == uid_ ? 0 : std::numeric_limits<size_t>::max();}
size_t size() const { return 1; }
private:
{%- for prop in properties %}
{{prop.type}} {{prop.name}}_;
{%- endfor %}
};
} //namespace data
} //namespace mesa_pd
} //namespace walberla
This diff is collapsed.
......@@ -31,6 +31,7 @@
#include <map>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <mesa_pd/data/ContactHistory.h>
......@@ -44,6 +45,7 @@
#include <core/Abort.h>
#include <core/debug/Debug.h>
#include <core/math/AABB.h>
#include <core/mpi/MPIWrapper.h>
#include <core/OpenMP.h>
#include <core/STLIO.h>
#include <core/UniqueID.h>
......
//======================================================================================================================
//
// 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.
//