AGX Dynamics  2.37.2.0
FlowRateConstraint.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 
18 #ifndef AGXHYDRAULICS_DETAIL_FLOW_RATE_CONSTRAINT_H
19 #define AGXHYDRAULICS_DETAIL_FLOW_RATE_CONSTRAINT_H
20 
21 #include <agx/Constraint.h>
24 
25 
26 /*
27 This file contains various constraint related classes used by the ConstantFlowValve.
28 */
29 
30 
31 namespace agxHydraulics
32 {
33  class FlowUnit;
34 
36  namespace detail
37  {
43  struct FlowRateConstraintData
44  {
45  agx::Real targetFlowRate;
46  agx::Real currentFlowRate;
47  agx::UInt8 elementIndex;
48  bool allowPumping;
49 
50  FlowRateConstraintData(agx::Real targetFlowRate, agx::UInt8 elementIndex, bool allowPumping);
51  };
52 
53 
54 
60  class ElementaryFlowRateConstraint : public agx::ElementaryConstraintN<1>
61  {
62  public:
63  ElementaryFlowRateConstraint(const FlowRateConstraintData& data);
64 
69  virtual void prepare() override;
70 
74  virtual agx::UInt getJacobian(
75  agx::Jacobian6DOFElement* G, agx::UInt numBlocks,
76  agx::UInt row, agx::GWriteState::Enum writeState) override;
77 
81  virtual agx::UInt getVelocity(agx::Real* v, agx::UInt row) const override;
82 
86  virtual agx::UInt getViolation(agx::Real* b, agx::UInt row) override;
87 
93  void setDataLocation(FlowRateConstraintData* data);
94 
95  AGXSTREAM_DECLARE_SERIALIZABLE(agxHydraulics::detail::ElementaryFlowRateConstraint);
96 
97  protected:
98  ElementaryFlowRateConstraint();
99  virtual ~ElementaryFlowRateConstraint() {}
100 
101  private:
102  // To avoid warning C4512. And these really should not be copyable.
103  void operator=(const ElementaryFlowRateConstraint&) {}
104 
105  private:
106  const FlowRateConstraintData* m_data;
107 
108  // The velocity used by getVelocity. Updated in prepare.
109  agx::Real m_constraintVelocity;
110  };
111 
112 
113  ElementaryFlowRateConstraint* asElementaryFlowRateConstraint(agx::Constraint* constraint);
114 
115 
116 
120  class FlowRateConstraintImplementation : public agx::ConstraintImplementation, public agxStream::Serializable
121  {
122  public:
123  FlowRateConstraintImplementation(const FlowRateConstraintData& data, FlowUnit* flowUnit);
124  void setFlowDimension(agxHydraulics::FlowDimension* flowDim);
125 
126  virtual void prepare() override;
127 
128  virtual void storeLightData(agxStream::StorageStream& str) const override;
129  virtual void restoreLightData(agxStream::StorageStream& str) override;
130 
131  AGXSTREAM_DECLARE_SERIALIZABLE(agxHydraulics::detail::FlowRateConstraintImplementation);
132 
133  protected:
134  virtual ~FlowRateConstraintImplementation() {}
135  FlowRateConstraintImplementation();
136 
137  private:
138  agxHydraulics::FlowDimension* m_flowDimension;
139  };
140 
141 
142 
143  AGX_DECLARE_POINTER_TYPES(FlowRateConstraint);
144 
160  class FlowRateConstraint : public agx::Constraint
161  {
162  public:
166  FlowRateConstraint(const FlowRateConstraintData& data, FlowUnit* flowUnit);
167  void setFlowDimension(agxHydraulics::FlowDimension* flowDim);
168  virtual void render(agxRender::RenderManager* canvas, float scale) const override;
169 
170  AGXSTREAM_DECLARE_SERIALIZABLE(agxHydraulics::detail::FlowRateConstraint);
171 
172  protected:
173  FlowRateConstraint();
174  virtual ~FlowRateConstraint();
175  virtual int getNumDOF() const override;
176 
177  private:
178  FlowRateConstraintImplementation* m_flowRateConstraint;
179  };
180 
181 
182  }
184 }
185 
186 
187 #endif
A FlowDimension represents the flow of fluid through a FlowUnit.
Definition: FlowDimension.h:53
uint8_t UInt8
Definition: Integer.h:38
Helper class to hold data that is general for elementary constraints.
The base class for a constraint.
Definition: Constraint.h:88
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc...
uint32_t UInt
Definition: Integer.h:34
The agxHydraulics namespace contains classes for modeling hydraulic circuits within the power line fr...
Definition: Accumulator.h:27
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:48
#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
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
double Real
Definition: Real.h:42