AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
FlowRateConstraint.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx 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/*
27This file contains various constraint related classes used by the ConstantFlowValve.
28*/
29
30
31namespace 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(
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
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
A FlowDimension represents the flow of fluid through a FlowUnit.
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc.
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Abstract base class for storing/restoring a line/drums with version control.
The base class for a constraint.
Definition Constraint.h:89
Helper class to hold data that is general for elementary constraints.
The agxHydraulics namespace contains classes for modeling hydraulic circuits within the power line fr...
Definition Accumulator.h:28
uint64_t UInt
Definition Integer.h:27
double Real
Definition Real.h:42
uint8_t UInt8
Definition Integer.h:30