AGX Dynamics  2.35.0.1
FlowUnit.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXHYDRAULICS_FLOW_UNIT_H
18 #define AGXHYDRAULICS_FLOW_UNIT_H
19 
22 
23 #include <agxPowerLine/Unit.h>
24 #include <agxPowerLine/Sides.h>
25 
26 namespace agx
27 {
28  class Constraint;
29 }
30 
31 namespace agxSDK
32 {
33  class Simulation;
34 }
35 
36 namespace agxModel
37 {
38  class DriveTrain;
39 }
40 
41 
42 
43 
44 namespace agxHydraulics
45 {
48 
49 
67  {
68  public:
75  FlowUnit(agx::Real length, agx::Real area, agx::Real fluidDensity);
76 
78  FlowUnit(agx::Real length, agx::Real area, agx::Real fluidDensity,
79  agx::RigidBody* body, agx::UInt8 elementIndex);
80 
82 
87  explicit FlowUnit(agx::Real inertia);
88 
93  void setLength(agx::Real length);
94 
98  agx::Real getLength() const;
99 
105  bool setArea(agx::Real area);
106 
110  agx::Real getArea() const;
111 
116  void setFluidDensity(agx::Real density);
117 
121  agx::Real getFluidDensity() const;
122 
130  void setFluidViscosity(agx::Real viscosity);
131 
135  agx::Real getFluidViscosity() const;
136 
141  agx::Real getFlowRate() const;
142 
151  void addPressure(agx::Real pressure, agxPowerLine::Side side);
152 
164  agx::Real getPressure(agxPowerLine::Side side) const;
165 
171  agx::Real getInputPressure() const;
172 
177  agx::Real getInletPressure() const;
178 
184  agx::Real getOutputPressure() const;
185 
190  agx::Real getOutletPressure() const;
191 
195  agxHydraulics::FlowDimension* getFlowDimension();
196 
200  const agxHydraulics::FlowDimension* getFlowDimension() const;
201 
202 
207  virtual agxHydraulics::FlowConnector* getFlowConnector(agxPowerLine::Side side);
208 
213  virtual const agxHydraulics::FlowConnector* getFlowConnector(agxPowerLine::Side side) const;
214 
219  agxHydraulics::FlowConnector* getInputFlowConnector();
220 
225  const agxHydraulics::FlowConnector* getInputFlowConnector() const;
226 
231  agxHydraulics::FlowConnector* getOutputFlowConnector();
232 
237  const agxHydraulics::FlowConnector* getOutputFlowConnector() const;
238 
243  bool isConnected(agxPowerLine::Side end) const;
244 
245  using Unit::isConnected;
246 
251  static FlowConnector* findInCommonFlowConnector(FlowUnit* a, FlowUnit* b);
252 
253 
254  // Methods called by the rest of the PowerLine/Hydraulics frame work.
255  public:
262  virtual agx::Real computeFrictionLoss(agx::Real flowRate);
263 
270  virtual void addTankPressure();
271 
272 #ifndef SWIG
276  virtual bool preUpdate(agx::Real timeStep) override;
277 
281  virtual bool store(agxStream::StorageStream& str) const override;
282 
286  virtual bool restore(agxStream::StorageStream& str) override;
287 
289 #endif
290 
291  protected:
295  FlowUnit();
297 
298  protected:
299  void init();
300 
301  void updateBodyMass();
302 
303  agx::Real computeReynoldsNumber() const;
304  static agx::Real computeReynoldsNumber(agx::Real area, agx::Real flowRate, agx::Real viscosity);
305  agx::Real computeFrictionFactor() const;
306  agx::Real computeLaminarFrictionalLoss(agx::Real flowRate) const;
307  agx::Real computeQuadraticFrictionalLoss(agx::Real flowCoefficient) const;
308  agx::Real updateFrictionLoss();
309 
310  protected:
311  virtual ~FlowUnit() {}
312 
313  protected:
315 
316  private:
317  agx::Real m_length;
318  agx::Real m_area;
319 
321  agx::Real m_fluidDensity;
322 
324  agx::Real m_viscosity;
325  };
326 
327 }
328 
329 #endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXHYDRAULICS_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
A FlowConnector is a junction of a set of FlowUnits.
Definition: FlowConnector.h:40
A FlowDimension represents the flow of fluid through a FlowUnit.
Definition: FlowDimension.h:54
FlowUnit is the base class for Units that contains a FlowDimension.
Definition: FlowUnit.h:67
agxHydraulics::FlowDimensionRef m_flowDimension
Definition: FlowUnit.h:314
FlowUnit(agx::Real length, agx::Real area, agx::Real fluidDensity)
Create a FlowUnit with inertia calculated from the given parameters.
Pure virtual class.
Definition: Unit.h:73
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:49
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
AGXHYDRAULICS_EXPORT void setFluidViscosity(agxPowerLine::PowerLine *powerLine, agx::Real viscosity)
Set the fluid viscosity of all FlowUnits in a PowerLine.
AGXHYDRAULICS_EXPORT void setFluidDensity(agxPowerLine::PowerLine *powerLine, agx::Real density)
Set the fluid density of all FlowUnits in a PowerLine.
The agxHydraulics namespace contains classes for modeling hydraulic circuits within the power line fr...
Definition: Accumulator.h:28
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:37
agxPowerLine contains a collection of connected components that transport power across a system.
Definition: MotorUnit.h:24
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition: Real.h:42
uint8_t UInt8
Definition: Integer.h:38
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
void AGXPHYSICS_EXPORT init()
Initialize agx.