24#ifndef WALL_CONTACT_HH
25#define WALL_CONTACT_HH
33template <
typename T,
unsigned D,
bool CONVEX>
34WallContactArbitraryFromOverlapVolume<
35 T, D, CONVEX>::WallContactArbitraryFromOverlapVolume()
40template <
typename T,
unsigned D,
bool CONVEX>
42 T, D, CONVEX>::WallContactArbitraryFromOverlapVolume(std::size_t particleID,
44 : particleID(std::array<std::size_t, 1>({particleID}))
45 , wallID(std::array<unsigned, 1>({wallID}))
51template <
typename T,
unsigned D,
bool CONVEX>
58 particleID[0] = contact.particleID[0];
59 wallID[0] = contact.wallID[0];
60 particlePosition = contact.particlePosition;
63 newContact[0] = contact.
isNew();
67template <
typename T,
unsigned D,
bool CONVEX>
72 min = std::move(contact.min);
73 max = std::move(contact.max);
74 particleID = std::move(contact.particleID);
75 wallID = std::move(contact.wallID);
76 particlePosition = std::move(contact.particlePosition);
77 particlePositionUpdated = std::move(contact.particlePositionUpdated);
78 dampingFactor = std::move(contact.dampingFactor);
79 newContact = std::move(contact.newContact);
80 responsibleRank = std::move(contact.responsibleRank);
83template <
typename T,
unsigned D,
bool CONVEX>
84constexpr const std::size_t&
87 return this->particleID[0];
90template <
typename T,
unsigned D,
bool CONVEX>
94 return this->wallID[0];
97template <
typename T,
unsigned D,
bool CONVEX>
101 return particlePosition;
104template <
typename T,
unsigned D,
bool CONVEX>
109 particlePosition = position;
110 particlePositionUpdated[0] =
true;
113template <
typename T,
unsigned D,
bool CONVEX>
118 responsibleRank[0] = rank;
121template <
typename T,
unsigned D,
bool CONVEX>
125 return responsibleRank[0];
128template <
typename T,
unsigned D,
bool CONVEX>
135template <
typename T,
unsigned D,
bool CONVEX>
142template <
typename T,
unsigned D,
bool CONVEX>
146 return dampingFactor[0];
149template <
typename T,
unsigned D,
bool CONVEX>
152 const T newDampingFactor)
154 dampingFactor[0] = newDampingFactor;
157template <
typename T,
unsigned D,
bool CONVEX>
160 const T coefficientOfRestitution,
161 const T initialRelativeVelocityMagnitude)
164 coefficientOfRestitution, initialRelativeVelocityMagnitude));
167template <
typename T,
unsigned D,
bool CONVEX>
171 for (
unsigned iD = 0; iD < D; ++iD) {
172 min[iD] = std::numeric_limits<olb::BaseType<T>>
::max();
173 max[iD] = -std::numeric_limits<olb::BaseType<T>>
::max();
175 particlePositionUpdated[0] =
false;
178template <
typename T,
unsigned D,
bool CONVEX>
184 positionInsideTheContact);
187template <
typename T,
unsigned D,
bool CONVEX>
192 this->max += increaseBy;
193 this->min -= increaseBy;
196template <
typename T,
unsigned D,
bool CONVEX>
200 if (particleID[0] == contact.particleID[0] &&
201 wallID[0] == contact.wallID[0]) {
202 if(contact.
isNew() == newContact[0]) {
204 for (
unsigned iD = 0; iD < D; ++iD) {
205 min[iD] =
util::min(min[iD], contact.min[iD]);
206 max[iD] =
util::max(max[iD], contact.max[iD]);
212 particlePositionUpdated[0] =
219 if(!contact.
isNew()) {
228 newContact[0] = newContact[0] && contact.
isNew();
236template <
typename T,
unsigned D,
bool CONVEX>
240 for (
unsigned iD = 0; iD < D; ++iD) {
241 if (min[iD] > max[iD]) {
248template <
typename T,
unsigned D,
bool CONVEX>
252 return newContact[0];
255template <
typename T,
unsigned D,
bool CONVEX>
257 const bool newContact)
259 this->newContact[0] = newContact;
262template <
typename T,
unsigned D,
bool CONVEX>
267 return particlePositionUpdated[0];
270template <
typename T,
unsigned D,
bool CONVEX>
275 particlePositionUpdated[0] = updated;
278template <
typename T,
unsigned D,
bool CONVEX>
285 particleID[0] = contact.particleID[0];
286 wallID[0] = contact.wallID[0];
287 particlePosition = contact.particlePosition;
290 newContact[0] = contact.
isNew();
296template <
typename T,
unsigned D,
bool CONVEX>
301 min = std::move(contact.min);
302 max = std::move(contact.max);
303 particleID = std::move(contact.particleID);
304 wallID = std::move(contact.wallID);
305 particlePosition = std::move(contact.particlePosition);
306 particlePositionUpdated = std::move(contact.particlePositionUpdated);
307 dampingFactor = std::move(contact.dampingFactor);
308 newContact = std::move(contact.newContact);
309 responsibleRank = std::move(contact.responsibleRank);
314template <
typename T,
unsigned D,
bool CONVEX>
327 auto communicatableParticlePositionUpdated =
332 return f(communicatablePosition, communicatableMin, communicatableMax,
333 communicatableID, communicatableMaterial, communicatableDamping,
334 communicatableParticlePositionUpdated, communicatableIsNew,
338template <
typename T,
unsigned D,
bool CONVEX>
340 std::uint8_t* buffer)
342 return processWithCommunicatables(
343 [&](
auto& communicatablePosition,
auto& communicatableMin,
344 auto& communicatableMax,
auto& communicatableID,
345 auto& communicatableMaterial,
auto& communicatableDamping,
346 auto& communicatableParticlePositionUpdated,
347 auto& communicatableIsNew,
auto& communicatableRank) {
348 std::size_t serialIdx =
349 communicatablePosition.serialize(this->indicesDim, buffer);
351 communicatableMin.serialize(this->indicesDim, &buffer[serialIdx]);
353 communicatableMax.serialize(this->indicesDim, &buffer[serialIdx]);
355 communicatableID.serialize(this->indicesSingle, &buffer[serialIdx]);
356 serialIdx += communicatableMaterial.serialize(this->indicesSingle,
358 serialIdx += communicatableDamping.serialize(this->indicesSingle,
360 serialIdx += communicatableParticlePositionUpdated.serialize(
361 this->indicesSingle, &buffer[serialIdx]);
362 serialIdx += communicatableIsNew.serialize(this->indicesSingle,
364 serialIdx += communicatableRank.serialize(this->indicesSingle,
371template <
typename T,
unsigned D,
bool CONVEX>
373 std::uint8_t* buffer)
375 return processWithCommunicatables(
376 [&](
auto& communicatablePosition,
auto& communicatableMin,
377 auto& communicatableMax,
auto& communicatableID,
378 auto& communicatableMaterial,
auto& communicatableDamping,
379 auto& communicatableParticlePositionUpdated,
380 auto& communicatableIsNew,
auto& communicatableRank) {
381 std::size_t serialIdx =
382 communicatablePosition.deserialize(this->indicesDim, buffer);
384 communicatableMin.deserialize(this->indicesDim, &buffer[serialIdx]);
386 communicatableMax.deserialize(this->indicesDim, &buffer[serialIdx]);
387 serialIdx += communicatableID.deserialize(this->indicesSingle,
389 serialIdx += communicatableMaterial.deserialize(this->indicesSingle,
391 serialIdx += communicatableDamping.deserialize(this->indicesSingle,
393 serialIdx += communicatableParticlePositionUpdated.deserialize(
394 this->indicesSingle, &buffer[serialIdx]);
395 serialIdx += communicatableIsNew.deserialize(this->indicesSingle,
397 serialIdx += communicatableRank.deserialize(this->indicesSingle,
404template <
typename T,
unsigned D,
bool CONVEX>
409#ifdef PARALLEL_MODE_MPI
411 if (rank == responsibleRank[0]) {
413 clout <<
"Min=" << this->min <<
", Max=" << this->max << std::endl;
414 clout <<
"particle ID=" << this->particleID[0]
415 <<
", wall ID=" << this->wallID[0]
416 <<
", DampingFactor=" << dampingFactor[0] << std::endl;
417 clout <<
"Position=" << particlePosition << std::endl;
418#ifdef PARALLEL_MODE_MPI
class for marking output with some text
void setMultiOutput(bool b)
enable message output for all MPI processes, disabled by default
int getRank() const
Returns the process ID.
void updateMinMax(PhysR< T, D > &min, PhysR< T, D > &max, const PhysR< T, D > &pos)
constexpr T evalDampingFactor(const T coefficientOfRestitution, const T initialRelativeVelocityMagnitude)
Calculates the damping factor according to Carvalho & Martins (2019) (10.1016/j.mechmachtheory....
Top level namespace for all of OpenLB.
constexpr T max(const ScalarVector< T, D, IMPL > &v)
constexpr bool isParticlePositionUpdated() const
Returns if the particle position is up-to-date.
constexpr void setResponsibleRank(const int &rank)
Set processor that is responsible for contact treatment.
constexpr void setDampingFactor(const T dampingFactor)
Set damping factor for contact.
void print()
Print relevant quantities.
constexpr void setParticlePosition(const PhysR< T, D > &particlePosition)
Set particle position.
constexpr void setDampingFactorFromInitialVelocity(const T coefficientOfRestitution, const T initialRelativeVelocityMagnitude)
Set damping factor from the magnitude of the initial relative impact velocity in direction of contact...
constexpr void setParticlePositionUpdated(bool updated)
constexpr const std::size_t & getParticleID() const
Read access to particle ID.
constexpr const PhysR< T, D > & getMin() const
Read access to min.
constexpr T getDampingFactor() const
Read access to damping factor.
std::size_t serialize(std::uint8_t *buffer)
Serialize contact data.
constexpr void resetMinMax()
Reset min and max to default values.
constexpr unsigned getWallID() const
Read access to wall matreial.
constexpr const int & getResponsibleRank() const
Read access to the responsible rank.
constexpr const PhysR< T, D > & getParticlePosition() const
Return particle position.
WallContactArbitraryFromOverlapVolume< T, D, CONVEX > & operator=(const WallContactArbitraryFromOverlapVolume< T, D, CONVEX > &contact)
Copy assignment.
WallContactArbitraryFromOverlapVolume()
Constructor.
constexpr bool isEmpty() const
Returns if contact holds data.
constexpr const PhysR< T, D > & getMax() const
Read access to max.
std::size_t deserialize(std::uint8_t *buffer)
Deserialize contact data and save in object.
constexpr void combineWith(WallContactArbitraryFromOverlapVolume< T, D, CONVEX > &contact)
Combining two contacts, if the particle IDs are the same.
constexpr bool isNew() const
Returns if the contact is a new contact.
constexpr void increaseMinMax(const Vector< T, D > &increaseBy)
Increase bounding box size.
constexpr void updateMinMax(const PhysR< T, D > &positionInsideTheContact)
Update min and max with given position inside the contact.