suanPan
RigidWallPenalty.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (C) 2017-2022 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  ******************************************************************************/
29 #ifndef RIGIDWALLPENALTY_H
30 #define RIGIDWALLPENALTY_H
31 
32 #include "Constraint.h"
33 #include <Domain/NodeHelper.hpp>
34 
35 class RigidWallPenalty : public Constraint {
36 protected:
37  template<DOF... D> void set_handler() { throw std::logic_error("not implemented"); }
38 
39  const unsigned n_dim;
40 
41  const double alpha;
42 
43  const vec edge_a, edge_b;
44  const vec origin, outer_norm;
45  const double length_a = 0., length_b = 0.;
46 
47  bool (*checker_handler)(const shared_ptr<Node>&) = nullptr;
48  Col<double> (*current_velocity_handler)(const shared_ptr<Node>&) = nullptr;
49  Col<double> (*incre_acceleration_handler)(const shared_ptr<Node>&) = nullptr;
50  Col<double> (*trial_position_handler)(const shared_ptr<Node>&) = nullptr;
51  Col<double> (*trial_displacement_handler)(const shared_ptr<Node>&) = nullptr;
52  Col<double> (*trial_velocity_handler)(const shared_ptr<Node>&) = nullptr;
53  Col<double> (*trial_acceleration_handler)(const shared_ptr<Node>&) = nullptr;
54 public:
55  RigidWallPenalty(unsigned, unsigned, unsigned, vec&&, vec&&, double, unsigned);
56  RigidWallPenalty(unsigned, unsigned, unsigned, vec&&, vec&&, vec&&, double, unsigned);
57 
58  int process(const shared_ptr<DomainBase>&) override;
59 
60  void commit_status() override;
61  void clear_status() override;
62  void reset_status() override;
63 };
64 
65 template<> inline void RigidWallPenalty::set_handler<DOF::U1>() {
66  checker_handler = check_dof_definition<DOF::U1>;
67  current_velocity_handler = get_current_velocity<DOF::U1>;
68  incre_acceleration_handler = get_incre_acceleration<DOF::U1>;
69  trial_position_handler = get_trial_position<DOF::U1>;
70  trial_displacement_handler = get_trial_displacement<DOF::U1>;
71  trial_velocity_handler = get_trial_velocity<DOF::U1>;
72  trial_acceleration_handler = get_trial_acceleration<DOF::U1>;
73 }
74 
75 template<> inline void RigidWallPenalty::set_handler<DOF::U1, DOF::U2>() {
76  checker_handler = check_dof_definition<DOF::U1, DOF::U2>;
77  current_velocity_handler = get_current_velocity<DOF::U1, DOF::U2>;
78  incre_acceleration_handler = get_incre_acceleration<DOF::U1, DOF::U2>;
79  trial_position_handler = get_trial_position<DOF::U1, DOF::U2>;
80  trial_displacement_handler = get_trial_displacement<DOF::U1, DOF::U2>;
81  trial_velocity_handler = get_trial_velocity<DOF::U1, DOF::U2>;
82  trial_acceleration_handler = get_trial_acceleration<DOF::U1, DOF::U2>;
83 }
84 
85 template<> inline void RigidWallPenalty::set_handler<DOF::U1, DOF::U2, DOF::U3>() {
86  checker_handler = check_dof_definition<DOF::U1, DOF::U2, DOF::U3>;
87  current_velocity_handler = get_current_velocity<DOF::U1, DOF::U2, DOF::U3>;
88  incre_acceleration_handler = get_incre_acceleration<DOF::U1, DOF::U2, DOF::U3>;
89  trial_position_handler = get_trial_position<DOF::U1, DOF::U2, DOF::U3>;
90  trial_displacement_handler = get_trial_displacement<DOF::U1, DOF::U2, DOF::U3>;
91  trial_velocity_handler = get_trial_velocity<DOF::U1, DOF::U2, DOF::U3>;
92  trial_acceleration_handler = get_trial_acceleration<DOF::U1, DOF::U2, DOF::U3>;
93 }
94 
95 class RigidWallPenalty1D final : public RigidWallPenalty {
96 public:
97  RigidWallPenalty1D(unsigned, unsigned, unsigned, vec&&, vec&&, double);
98 };
99 
100 class RigidWallPenalty2D final : public RigidWallPenalty {
101 public:
102  RigidWallPenalty2D(unsigned, unsigned, unsigned, vec&&, vec&&, double);
103  RigidWallPenalty2D(unsigned, unsigned, unsigned, vec&&, vec&&, vec&&, double);
104 };
105 
106 class RigidWallPenalty3D final : public RigidWallPenalty {
107 public:
108  RigidWallPenalty3D(unsigned, unsigned, unsigned, vec&&, vec&&, double);
109  RigidWallPenalty3D(unsigned, unsigned, unsigned, vec&&, vec&&, vec&&, double);
110 };
111 
112 #endif
113 
A Constraint class.
Definition: Constraint.h:36
Definition: RigidWallPenalty.h:95
RigidWallPenalty1D(unsigned, unsigned, unsigned, vec &&, vec &&, double)
Definition: RigidWallPenalty.cpp:79
Definition: RigidWallPenalty.h:100
RigidWallPenalty2D(unsigned, unsigned, unsigned, vec &&, vec &&, double)
Definition: RigidWallPenalty.cpp:82
Definition: RigidWallPenalty.h:106
RigidWallPenalty3D(unsigned, unsigned, unsigned, vec &&, vec &&, double)
Definition: RigidWallPenalty.cpp:93
A RigidWall class.
Definition: RigidWallPenalty.h:35
Col< double >(* trial_acceleration_handler)(const shared_ptr< Node > &)
Definition: RigidWallPenalty.h:53
const vec origin
Definition: RigidWallPenalty.h:44
Col< double >(* trial_displacement_handler)(const shared_ptr< Node > &)
Definition: RigidWallPenalty.h:51
bool(* checker_handler)(const shared_ptr< Node > &)
Definition: RigidWallPenalty.h:47
void clear_status() override
Definition: RigidWallPenalty.cpp:75
const double alpha
Definition: RigidWallPenalty.h:41
Col< double >(* current_velocity_handler)(const shared_ptr< Node > &)
Definition: RigidWallPenalty.h:48
Col< double >(* incre_acceleration_handler)(const shared_ptr< Node > &)
Definition: RigidWallPenalty.h:49
void reset_status() override
Definition: RigidWallPenalty.cpp:77
const unsigned n_dim
Definition: RigidWallPenalty.h:39
int process(const shared_ptr< DomainBase > &) override
This method provides all necessary pieces of typical constraints/loads required, including additional...
Definition: RigidWallPenalty.cpp:40
const double length_b
Definition: RigidWallPenalty.h:45
const vec edge_a
Definition: RigidWallPenalty.h:43
void commit_status() override
Definition: RigidWallPenalty.cpp:73
const double length_a
Definition: RigidWallPenalty.h:45
void set_handler()
Definition: RigidWallPenalty.h:37
Col< double >(* trial_velocity_handler)(const shared_ptr< Node > &)
Definition: RigidWallPenalty.h:52
Col< double >(* trial_position_handler)(const shared_ptr< Node > &)
Definition: RigidWallPenalty.h:50
const vec outer_norm
Definition: RigidWallPenalty.h:44
RigidWallPenalty(unsigned, unsigned, unsigned, vec &&, vec &&, double, unsigned)
Definition: RigidWallPenalty.cpp:22
const vec edge_b
Definition: RigidWallPenalty.h:43
DOF
Definition: DOF.h:29