suanPan
🧮 An Open Source, Parallel and Heterogeneous Finite Element Analysis Framework
Loading...
Searching...
No Matches
Interaction.h
Go to the documentation of this file.
1/*******************************************************************************
2 * Copyright (C) 2017-2026 Theodore Chang
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ******************************************************************************/
27#ifndef INTERACTION_H
28#define INTERACTION_H
29
30#include <Domain/Tag.h>
31#include <set>
32
33class DomainBase;
34class Element;
35
37 const shared_ptr<Element> object_i, object_j;
38
39 bool inertial = false;
40 unsigned dimension{};
41
42public:
47
48 InteractionPair(const shared_ptr<Element>&, const shared_ptr<Element>&);
49
50 void set_dimension(const unsigned dim) { dimension = dim; }
51 void set_inertial(const bool flag) { inertial = flag; }
52
53 [[nodiscard]] vec position_i() const;
54 [[nodiscard]] vec position_j() const;
55
56 [[nodiscard]] vec velocity_i() const;
57 [[nodiscard]] vec velocity_j() const;
58
59 [[nodiscard]] const uvec& dof_i() const;
60 [[nodiscard]] const uvec& dof_j() const;
61
62 [[nodiscard]] double initial_gap() const;
63};
64
65class Interaction : public CopyableTag {
66protected:
67 std::weak_ptr<DomainBase> domain;
68
69public:
71
72 void initialize(const shared_ptr<DomainBase>&);
73
74 virtual void apply(bool, const shared_ptr<Element>&) const = 0;
75 virtual void apply(bool, const shared_ptr<InteractionPair>&) const = 0;
76};
77
78class Hertzian final : public Interaction {
79 static constexpr double four_third = 4. / 3.;
80
81public:
82 using Interaction::Interaction;
83
84 void apply(bool, const shared_ptr<Element>&) const override {}
85 void apply(bool, const shared_ptr<InteractionPair>&) const override;
86};
87
88class FixedParticle final : public Interaction {
89 std::set<unsigned> particles;
90 const double multiplier;
91
92public:
93 FixedParticle(unsigned, double, std::set<unsigned>&&);
94
95 void apply(bool, const shared_ptr<Element>&) const override;
96 void apply(bool, const shared_ptr<InteractionPair>&) const override {}
97};
98
99#endif
100
Label objects that can be copied.
Definition Tag.h:73
CopyableTag(const CopyableTag &)=default
The DomainBase class is a template.
Definition DomainBase.h:94
A Element class.
Definition Element.h:118
Definition Interaction.h:88
void apply(bool, const shared_ptr< Element > &) const override
Definition Interaction.cpp:119
void apply(bool, const shared_ptr< InteractionPair > &) const override
Definition Interaction.h:96
Definition Interaction.h:78
void apply(bool, const shared_ptr< Element > &) const override
Definition Interaction.h:84
Definition Interaction.h:65
virtual void apply(bool, const shared_ptr< Element > &) const =0
void initialize(const shared_ptr< DomainBase > &)
Definition Interaction.cpp:49
std::weak_ptr< DomainBase > domain
Definition Interaction.h:67
virtual void apply(bool, const shared_ptr< InteractionPair > &) const =0
Definition Interaction.h:36
double effective_damping
Definition Interaction.h:46
double effective_mass
Definition Interaction.h:43
vec velocity_i() const
Definition Interaction.cpp:39
void set_dimension(const unsigned dim)
Definition Interaction.h:50
void set_inertial(const bool flag)
Definition Interaction.h:51
double effective_modulus
Definition Interaction.h:45
vec position_j() const
Definition Interaction.cpp:37
double effective_radius
Definition Interaction.h:44
double initial_gap() const
Definition Interaction.cpp:47
const uvec & dof_j() const
Definition Interaction.cpp:45
vec velocity_j() const
Definition Interaction.cpp:41
vec position_i() const
Definition Interaction.cpp:35
const uvec & dof_i() const
Definition Interaction.cpp:43