Free Electron
SoftSystem.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_SoftSystem_h__
8 #define __tire_SoftSystem_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 ExternalForce : public SemiImplicit::Force,
21  public CastableAs<ExternalForce>
22 {
23  public:
24  ExternalForce(sp<SemiImplicit> a_integrator) {}
25 virtual ~ExternalForce(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 Soft System
63 class SoftSystem : //MOA basic soft body system
64  virtual public Stepper,
65  public Initialize<SoftSystem>
66 {
67  public:
68  SoftSystem(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 Soft
76  {
77  WeakRecord m_r_parent;
78  sp<SemiImplicit> m_spSemiImplicit;
79 
80  std::vector< sp<ExternalForce> > m_spExternalForces;
81  std::vector<Record> m_forceParticles;
82  };
83 
84  sp<Scope> m_spScope;
85 
86  std::vector<Soft> m_softs;
87  AsSoft m_asSoft;
88 };
89 
90 } /* namespace ext */
91 } /* namespace fe */
92 
93 #endif /* __tire_SoftSystem_h__ */
kernel
Definition: namespace.dox:3
Time Stepping System.
Definition: Stepper.h:15
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Soft System.
Definition: SoftSystem.h:63
Non-persistent reference to an instance of a Layout.
Definition: WeakRecordSB.h:17