OpenLB 1.7
Loading...
Searching...
No Matches
contactProperties.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2022 Jan E. Marquardt, Mathias J. Krause
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef CONTACT_PROPERTIES_HH
25#define CONTACT_PROPERTIES_HH
26
27#include "contactProperties.h"
28#include "core/olbDebug.h"
30
31namespace olb {
32namespace particles {
33namespace contact {
34
35template <typename T, unsigned N, bool ENABLE_RANGE_CHECK>
36constexpr inline unsigned
37ContactProperties<T, N, ENABLE_RANGE_CHECK>::getIndex(unsigned materialA,
38 unsigned materialB) const
39{
40 const unsigned minMat {util::min(materialA, materialB)};
41 const unsigned maxMat {util::max(materialA, materialB)};
42 const unsigned index {(maxMat + 1) * maxMat / 2 + minMat};
43
44 // Optional range check - for debugging
45 if constexpr (ENABLE_RANGE_CHECK) {
46 OLB_ASSERT(index >= 0 && index <= N,
47 "ERROR: ContactProperties material is not defined");
48 }
49
50 return index;
51}
52
53template <typename T, unsigned N, bool ENABLE_RANGE_CHECK>
55 const unsigned materialA, const unsigned materialB,
56 const T effectiveYoungsModulus, const T coefficientOfRestitution,
57 const T coefficientKineticFriction, const T coefficientStaticFriction,
58 const T staticKineticTransitionVelocity)
59{
60 if (materialA >= N || materialB >= N) {
61 std::cerr << "WARNING: At least one of the provided materials exceeds the "
62 "total number of materials."
63 << std::endl;
64 }
65
66 data[getIndex(materialA, materialB)] =
67 ContactProperty(effectiveYoungsModulus, coefficientOfRestitution,
68 coefficientKineticFriction, coefficientStaticFriction,
69 staticKineticTransitionVelocity);
70}
71
72template <typename T, unsigned N, bool ENABLE_RANGE_CHECK>
73constexpr T
75 const unsigned materialA, const unsigned materialB) const
76{
77 return data[getIndex(materialA, materialB)].effectiveYoungsModulus;
78}
79
80template <typename T, unsigned N, bool ENABLE_RANGE_CHECK>
81constexpr T
83 const unsigned materialA, const unsigned materialB) const
84{
85 return data[getIndex(materialA, materialB)].coefficientOfRestitution;
86}
87
88template <typename T, unsigned N, bool ENABLE_RANGE_CHECK>
89constexpr T
91 const unsigned materialA, const unsigned materialB) const
92{
93 return data[getIndex(materialA, materialB)].coefficientOfKineticFriction;
94}
95
96template <typename T, unsigned N, bool ENABLE_RANGE_CHECK>
97constexpr T
99 const unsigned materialA, const unsigned materialB) const
100{
101 return data[getIndex(materialA, materialB)].coefficientOfStaticFriction;
102}
103
104template <typename T, unsigned N, bool ENABLE_RANGE_CHECK>
105constexpr T
107 const unsigned materialA, const unsigned materialB) const
108{
109 return data[getIndex(materialA, materialB)].staticKineticTransitionVelocity;
110}
111
112} // namespace contact
113} // namespace particles
114} // namespace olb
115#endif
cpu::simd::Pack< T > min(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:124
cpu::simd::Pack< T > max(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:130
Top level namespace for all of OpenLB.
#define OLB_ASSERT(COND, MESSAGE)
Definition olbDebug.h:45
constexpr T getKineticFrictionCoefficient(const unsigned materialA, const unsigned materialB) const
Get coefficient of kinetic friction.
constexpr T getStaticKineticTransitionVelocity(const unsigned materialA, const unsigned materialB) const
Get transition velocity (static to kinetic)
constexpr T getStaticFrictionCoefficient(const unsigned materialA, const unsigned materialB) const
Get coefficient of static friction.
constexpr void set(const unsigned materialA, const unsigned materialB, const T effectiveYoungsModulus, const T coefficientOfRestitution, const T coefficientKineticFriction, const T coefficientStaticFriction, const T staticKineticTransitionVelocity=T {0.01})
Set contact properties.
constexpr T getCoefficientOfRestitution(const unsigned materialA, const unsigned materialB) const
Get damping constant.
constexpr T getEffectiveYoungsModulus(const unsigned materialA, const unsigned materialB) const
Get effective modulus of elasticity.