Free Electron
SemiImplicitDriveline.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 __driveline_SemiImplicitDriveline_h__
8 #define __driveline_SemiImplicitDriveline_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 class FE_DL_EXPORT DrivelineItem : public SemiImplicit1D::Force,
16  public CastableAs<DrivelineItem>
17 {
18  public:
19  DrivelineItem(void);
20 virtual ~DrivelineItem(void);
21 
22  void setDriveline(sp<DrivelineI> a_spDriveLine)
23  { m_spDriveLine = a_spDriveLine; }
24 
25  protected:
26  hp<DrivelineI> m_spDriveLine;
27 
28 };
29 
30 class ShaftForce : public DrivelineItem, public CastableAs<ShaftForce>
31 {
32  public:
33  ShaftForce(sp<SemiImplicit1D> a_integrator)
34  {
35  m_force = 0.0;
36  }
37 virtual ~ShaftForce(void) {}
38 
39  void bind(SemiImplicit1D::Particle *a_particle)
40  {
41  m_particle = a_particle;
42  }
43 
44 virtual void accumulate(void)
45  {
46  m_particle->m_force += (t_solve_real)(m_force);
47  }
48 
49  void set(const t_solve_real &a_force)
50  {
51  m_force = a_force * m_particle->m_ratio;
52 fe_fprintf(stderr, "FRC %g %g\n", m_force, a_force);
53  }
54  t_solve_real get(void)
55  {
56  return m_particle->m_force / m_particle->m_ratio;
57  }
58  t_solve_real location(void)
59  {
60  return m_particle->m_location_ratio;
61  }
62  t_solve_real velocity(void)
63  {
64  return m_particle->m_velocity * m_particle->m_ratio;
65  }
66  t_solve_real coreVelocity(void)
67  {
68  return m_particle->m_velocity;
69  }
70  void setvelocity(const t_solve_real &a_value)
71  {
72  m_particle->m_velocity = a_value / m_particle->m_ratio;
73  }
74 
75  private:
76  SemiImplicit1D::Particle *m_particle;
77  t_solve_real m_force;
78 };
79 
80 /// @brief Driveline Solver
81 class FE_DL_EXPORT SemiImplicitDriveline
82  : virtual public DrivelineI,
83  public CastableAs<SemiImplicitDriveline>
84 {
85  public:
87 virtual ~SemiImplicitDriveline(void);
88 
89 virtual void initialize(void);
90 
91 virtual void step(t_moa_real a_dt);
92 virtual void sync(void);
93 virtual bool compile(Record r_driveline);
94 
95  class Shaft
96  {
97  public:
98  Record m_r_parent;
99  sp<ShaftForce> m_spHookForce;
100  bool m_has_externalTorque;
101  };
102 
103  private:
104  sp<SemiImplicit1D> m_spSemiImplicit;
105  sp<RecordGroup> m_rg_driveline;
106  AsParticle1D m_asParticle1D;
107  AsSolverParticle1D m_asSolverParticle;
108  AsShaft m_asShaft;
109  AsExternalTorque m_asExternalTorque;
110  std::map< String, Shaft > m_shafts;
111 
112 };
113 
114 } /* namespace ext */
115 } /* namespace fe */
116 
117 #endif /* __driveline_SemiImplicitDriveline_h__ */
118 
Driveline Solver.
Definition: SemiImplicitDriveline.h:81
kernel
Definition: namespace.dox:3
Reference to an instance of a Layout.
Definition: RecordSB.h:35
particle in physical space
Definition: shapeAS.h:114
Driveline Shaft.
Definition: drivelineAS.h:29
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192