Free Electron
TireRig.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __tire_TireRig_h__
8 #define __tire_TireRig_h__
9 
10 #include "solve/solve.h"
11 #include "evaluate/evaluate.h"
12 #include "evaluate/Function.h"
13 
14 namespace fe
15 {
16 namespace ext
17 {
18 
19 // Force for internal use
20 class TireRigForce : public SemiImplicit::Force,
21  public CastableAs<TireRigForce>
22 {
23  public:
24  TireRigForce(sp<SemiImplicit> a_integrator) {}
25 virtual ~TireRigForce(void) {}
26 
27  void bind(SemiImplicit::Particle *a_particle)
28  {
29  m_particle = a_particle;
30  }
31 
32 virtual void accumulate(void)
33  {
34  m_particle->m_force[0] += (t_solve_real)(m_force[0]);
35  m_particle->m_force[1] += (t_solve_real)(m_force[1]);
36  m_particle->m_force[2] += (t_solve_real)(m_force[2]);
37  }
38 
39  void set(const t_moa_v3 &a_force)
40  {
41  m_force = a_force;
42  }
43  void add(const t_moa_v3 &a_force)
44  {
45  m_force += a_force;
46  }
47  t_solve_v3 location(void)
48  {
49  return m_particle->m_location;
50  }
51  t_solve_v3 velocity(void)
52  {
53  return m_particle->m_velocity;
54  }
55 
56  private:
57  SemiImplicit::Particle *m_particle;
58  t_moa_v3 m_force;
59 };
60 
61 
62 /// @brief Tire Test Rig System
63 class RigSystem :
64  virtual public Stepper,
65  public Initialize<RigSystem>
66 {
67  public:
68  RigSystem(void)
69  {
70  }
71  void initialize(void) {}
72 virtual void compile(const t_note_id &a_note_id);
73  void step(t_moa_real a_dt);
74 
75  struct Rig
76  {
77  WeakRecord m_r_parent;
78  sp<TireRigForce> m_spTireForce;
79  sp<SemiImplicit> m_spSemiImplicit;
80  SemiImplicit::Particle *m_particle;
81  void makeWishbone(RigSystem &a_system, t_moa_real a_stiffness,
82  t_moa_real a_damping, t_moa_real a_load);
83 
84  std::vector< sp<TireRigForce> > m_spTireForces;
85  std::vector<Record> m_forceParticles;
86  };
87 
88  sp<Scope> m_spScope;
89 
90  std::vector<Rig> m_rigs;
91  AsRigLive m_asRig;
92 };
93 
94 } /* namespace ext */
95 } /* namespace fe */
96 
97 #endif /* __tire_TireRig_h__ */
Tire Test Rig Live.
Definition: tireAS.h:206
kernel
Definition: namespace.dox:3
Time Stepping System.
Definition: Stepper.h:15
Tire Test Rig System.
Definition: TireRig.h:63
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
Non-persistent reference to an instance of a Layout.
Definition: WeakRecordSB.h:17