MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
DynamicPipe Class Reference

#include <pipe.h>

Inheritance diagram for DynamicPipe:
Collaboration diagram for DynamicPipe:

Public Member Functions

 DynamicPipe (unsigned int uL, const DofOwner *pD, HydraulicFluid *hf, const PressureNode *p1, const PressureNode *p2, doublereal Dh, doublereal A, doublereal L, flag transition, doublereal q0, flag fOut)
 
 ~DynamicPipe (void)
 
virtual HydraulicElem::Type GetHydraulicType (void) const
 
virtual std::ostream & Restart (std::ostream &out) const
 
virtual unsigned int iGetNumDof (void) const
 
virtual DofOrder::Order GetDofType (unsigned int i) const
 
virtual DofOrder::Order GetEqType (unsigned int i) const
 
virtual void WorkSpaceDim (integer *piNumRows, integer *piNumCols) const
 
VariableSubMatrixHandlerAssJac (VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
SubVectorHandlerAssRes (SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void AfterConvergence (const VectorHandler &X, const VectorHandler &XP)
 
virtual void Output (OutputHandler &OH) const
 
virtual void SetValue (DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *ph=0)
 
virtual void GetConnectedNodes (std::vector< const Node * > &connectedNodes) const
 
- Public Member Functions inherited from Elem
 Elem (unsigned int uL, flag fOut)
 
virtual ~Elem (void)
 
virtual std::ostream & DescribeDof (std::ostream &out, const char *prefix="", bool bInitial=false) const
 
virtual void DescribeDof (std::vector< std::string > &desc, bool bInitial=false, int i=-1) const
 
virtual std::ostream & DescribeEq (std::ostream &out, const char *prefix="", bool bInitial=false) const
 
virtual void DescribeEq (std::vector< std::string > &desc, bool bInitial=false, int i=-1) const
 
virtual void AssMats (VariableSubMatrixHandler &WorkMatA, VariableSubMatrixHandler &WorkMatB, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual bool bInverseDynamics (void) const
 
void SetInverseDynamicsFlags (unsigned uIDF)
 
unsigned GetInverseDynamicsFlags (void) const
 
bool bIsErgonomy (void) const
 
bool bIsRightHandSide (void) const
 
virtual VariableSubMatrixHandlerAssJac (VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
 
virtual SubVectorHandlerAssRes (SubVectorHandler &WorkVec, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr, const VectorHandler &XPrimePrimeCurr, InverseDynamics::Order iOrder=InverseDynamics::INVERSE_DYNAMICS)
 
virtual int GetNumConnectedNodes (void) const
 
- Public Member Functions inherited from WithLabel
 WithLabel (unsigned int uL=0, const std::string &sN="")
 
virtual ~WithLabel (void)
 
void PutLabel (unsigned int uL)
 
void PutName (const std::string &sN)
 
unsigned int GetLabel (void) const
 
const std::string & GetName (void) const
 
- Public Member Functions inherited from SimulationEntity
 SimulationEntity (void)
 
virtual ~SimulationEntity (void)
 
virtual bool bIsValidIndex (unsigned int i) const
 
virtual HintParseHint (DataManager *pDM, const char *s) const
 
virtual void BeforePredict (VectorHandler &, VectorHandler &, VectorHandler &, VectorHandler &) const
 
virtual void AfterPredict (VectorHandler &X, VectorHandler &XP)
 
virtual void Update (const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void DerivativesUpdate (const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void Update (const VectorHandler &XCurr, InverseDynamics::Order iOrder)
 
virtual void AfterConvergence (const VectorHandler &X, const VectorHandler &XP, const VectorHandler &XPP)
 
virtual unsigned int iGetNumPrivData (void) const
 
virtual unsigned int iGetPrivDataIdx (const char *s) const
 
virtual doublereal dGetPrivData (unsigned int i) const
 
virtual std::ostream & OutputAppend (std::ostream &out) const
 
virtual void ReadInitialState (MBDynParser &HP)
 
- Public Member Functions inherited from ToBeOutput
 ToBeOutput (flag fOut=fDefaultOut)
 
virtual ~ToBeOutput (void)
 
virtual void OutputPrepare (OutputHandler &OH)
 
virtual void Output (OutputHandler &OH, const VectorHandler &X, const VectorHandler &XP) const
 
virtual flag fToBeOutput (void) const
 
virtual bool bToBeOutput (void) const
 
virtual void SetOutputFlag (flag f=flag(1))
 
- Public Member Functions inherited from HydraulicElem
 HydraulicElem (unsigned int uL, const DofOwner *pDO, HydraulicFluid *hf, flag fOut)
 
virtual ~HydraulicElem (void)
 
virtual Elem::Type GetElemType (void) const
 
- Public Member Functions inherited from ElemWithDofs
 ElemWithDofs (unsigned int uL, const DofOwner *pDO, flag fOut)
 
virtual ~ElemWithDofs (void)
 
- Public Member Functions inherited from DofOwnerOwner
 DofOwnerOwner (const DofOwner *pDO)
 
virtual ~DofOwnerOwner ()
 
virtual const DofOwnerpGetDofOwner (void) const
 
virtual integer iGetFirstIndex (void) const
 
virtual void SetInitialValue (VectorHandler &X)
 

Private Attributes

const PressureNodepNode1
 
const PressureNodepNode2
 
doublereal diameter
 
doublereal area
 
doublereal length
 
flag turbulent
 
doublereal q0
 
doublereal Re
 
doublereal p1
 
doublereal p2
 
doublereal p1p
 
doublereal p2p
 
doublereal q1
 
doublereal q2
 
doublereal q1p
 
doublereal q2p
 
doublereal density1
 
doublereal density0
 
doublereal density2
 
doublereal densityDPres1
 
doublereal densityDPres2
 
doublereal viscosity
 
doublereal dKlam
 
doublereal dKtrb
 
doublereal dKtra
 

Additional Inherited Members

- Public Types inherited from Elem
enum  Type {
  UNKNOWN = -1, AIRPROPERTIES = 0, INDUCEDVELOCITY, AUTOMATICSTRUCTURAL,
  GRAVITY, BODY, JOINT, JOINT_REGULARIZATION,
  BEAM, PLATE, FORCE, INERTIA,
  ELECTRICBULK, ELECTRIC, THERMAL, HYDRAULIC,
  BULK, LOADABLE, DRIVEN, EXTERNAL,
  AEROMODAL, AERODYNAMIC, GENEL, SOCKETSTREAM_OUTPUT,
  RTAI_OUTPUT = SOCKETSTREAM_OUTPUT, LASTELEMTYPE
}
 
- Public Types inherited from SimulationEntity
typedef std::vector< Hint * > Hints
 
- Public Types inherited from ToBeOutput
enum  { OUTPUT = 0x1U, OUTPUT_MASK = 0xFU, OUTPUT_PRIVATE = 0x10U, OUTPUT_PRIVATE_MASK = ~OUTPUT_MASK }
 
- Public Types inherited from HydraulicElem
enum  Type {
  UNKNOWN = -1, MINOR_LOSS = 0, THREEWAYMINORLOSS, CONTROL_VALVE,
  DYNAMIC_CONTROL_VALVE, PRESSURE_FLOW_CONTROL_VALVE, PRESSURE_VALVE, FLOW_VALVE,
  ORIFICE, ACCUMULATOR, TANK, PIPE,
  DYNAMIC_PIPE, HYDRAULIC_ACTUATOR, ACTUATOR, LASTHYDRAULICTYPE
}
 
- Protected Attributes inherited from WithLabel
unsigned int uLabel
 
std::string sName
 
- Protected Attributes inherited from ToBeOutput
flag fOutput
 
- Protected Attributes inherited from HydraulicElem
HydraulicFluidHF
 

Detailed Description

Definition at line 201 of file pipe.h.

Constructor & Destructor Documentation

DynamicPipe::DynamicPipe ( unsigned int  uL,
const DofOwner pD,
HydraulicFluid hf,
const PressureNode p1,
const PressureNode p2,
doublereal  Dh,
doublereal  A,
doublereal  L,
flag  transition,
doublereal  q0,
flag  fOut 
)

Definition at line 1006 of file pipe.cc.

References area, ASSERT, diameter, dKlam, dKtra, dKtrb, PressureNode::GetNodeType(), Node::HYDRAULIC, length, pNode1, pNode2, and grad::pow().

1017 : Elem(uL, fOut),
1018 HydraulicElem(uL, pDO, hf, fOut),
1019 pNode1(p1),
1020 pNode2(p2),
1021 diameter(Dh),
1022 area(A),
1023 length(L),
1024 turbulent(transition),
1025 q0(q0)
1026 {
1027  ASSERT(pNode1 != NULL);
1029  ASSERT(pNode2 != NULL);
1031 
1032  ASSERT(Dh > std::numeric_limits<doublereal>::epsilon());
1033  ASSERT(A > std::numeric_limits<doublereal>::epsilon());
1034  ASSERT(L > std::numeric_limits<doublereal>::epsilon());
1035 
1036  dKlam = 16.*length/(diameter*diameter);
1037  dKtra = .25*length/(diameter*area);
1038  dKtrb = .5*length*.1582/(pow(diameter, 1.25)*pow(area, .75));
1039 }
const PressureNode * pNode1
Definition: pipe.h:203
doublereal dKtrb
Definition: pipe.h:234
GradientExpression< BinaryExpr< FuncPow, LhsExpr, RhsExpr > > pow(const GradientExpression< LhsExpr > &u, const GradientExpression< RhsExpr > &v)
Definition: gradient.h:2961
doublereal q0
Definition: pipe.h:211
doublereal length
Definition: pipe.h:208
doublereal diameter
Definition: pipe.h:206
HydraulicElem(unsigned int uL, const DofOwner *pDO, HydraulicFluid *hf, flag fOut)
Definition: preselem.cc:54
doublereal dKtra
Definition: pipe.h:235
doublereal dKlam
Definition: pipe.h:233
const PressureNode * pNode2
Definition: pipe.h:204
#define ASSERT(expression)
Definition: colamd.c:977
flag turbulent
Definition: pipe.h:210
virtual Node::Type GetNodeType(void) const
Definition: presnode.h:54
doublereal area
Definition: pipe.h:207
Elem(unsigned int uL, flag fOut)
Definition: elem.cc:41

Here is the call graph for this function:

DynamicPipe::~DynamicPipe ( void  )

Definition at line 1041 of file pipe.cc.

References NO_OP.

1042 {
1043  NO_OP;
1044 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

void DynamicPipe::AfterConvergence ( const VectorHandler X,
const VectorHandler XP 
)
virtual

Reimplemented from SimulationEntity.

Definition at line 1353 of file pipe.cc.

References DEBUGCOUT, HydraulicFluid::dGetRe(), WithLabel::GetLabel(), HydraulicElem::HF, HydraulicFluid::LOWER, Re, turbulent, and HydraulicFluid::UPPER.

1354 {
1355  if (Re < HF->dGetRe(HydraulicFluid::LOWER)) {
1356  turbulent = 0;
1357  } else if (Re > HF->dGetRe(HydraulicFluid::UPPER)) {
1358  turbulent = 1;
1359  }
1360 
1361 #ifdef HYDR_DEVEL
1362  DEBUGCOUT("DynamicPipe(" << GetLabel() << "): turbulent mode = "
1363  << turbulent << std::endl);
1364 #endif /* HYDR_DEVEL */
1365 }
virtual doublereal dGetRe(Re which)
Definition: hfluid.h:95
doublereal Re
Definition: pipe.h:213
HydraulicFluid * HF
Definition: preselem.h:79
#define DEBUGCOUT(msg)
Definition: myassert.h:232
flag turbulent
Definition: pipe.h:210
unsigned int GetLabel(void) const
Definition: withlab.cc:62

Here is the call graph for this function:

VariableSubMatrixHandler & DynamicPipe::AssJac ( VariableSubMatrixHandler WorkMat,
doublereal  dCoef,
const VectorHandler XCurr,
const VectorHandler XPrimeCurr 
)
virtual

Implements Elem.

Definition at line 1084 of file pipe.cc.

References a, area, c, density0, density1, density2, densityDPres1, densityDPres2, HydraulicFluid::dGetDensityDPres(), HydraulicFluid::dGetRe(), diameter, dKlam, dKtrb, grad::fabs(), HydraulicElem::HF, Node::iGetFirstColIndex(), DofOwnerOwner::iGetFirstIndex(), Node::iGetFirstRowIndex(), length, HydraulicFluid::LOWER, p1, p2, pNode1, pNode2, grad::pow(), FullSubMatrixHandler::PutCoef(), FullSubMatrixHandler::PutColIndex(), FullSubMatrixHandler::PutRowIndex(), q1, q2, Re, FullSubMatrixHandler::ResizeReset(), VariableSubMatrixHandler::SetFull(), turbulent, HydraulicFluid::UPPER, and viscosity.

1088 {
1089  FullSubMatrixHandler& WM = WorkMat.SetFull();
1090  WM.ResizeReset(6, 6);
1091 
1092  integer iNode1RowIndex = pNode1->iGetFirstRowIndex()+1;
1093  integer iNode2RowIndex = pNode2->iGetFirstRowIndex()+1;
1094  integer iNode1ColIndex = pNode1->iGetFirstColIndex()+1;
1095  integer iNode2ColIndex = pNode2->iGetFirstColIndex()+1;
1096 
1097  integer iFirstIndex = iGetFirstIndex();
1098 
1099  WM.PutRowIndex(1, iNode1RowIndex);
1100  WM.PutRowIndex(2, iNode2RowIndex);
1101  WM.PutRowIndex(3, iFirstIndex+1);
1102  WM.PutRowIndex(4, iFirstIndex+2);
1103  WM.PutRowIndex(5, iFirstIndex+3);
1104  WM.PutRowIndex(6, iFirstIndex+4);
1105 
1106  WM.PutColIndex(1, iNode1ColIndex);
1107  WM.PutColIndex(2, iNode2ColIndex);
1108  WM.PutColIndex(3, iFirstIndex+1);
1109  WM.PutColIndex(4, iFirstIndex+2);
1110  WM.PutColIndex(5, iFirstIndex+3);
1111  WM.PutColIndex(6, iFirstIndex+4);
1112 
1113  doublereal dRDP1 = HF->dGetDensityDPres(p1);
1114  doublereal dRDP2 = HF->dGetDensityDPres(p2);
1115  doublereal dRDP0 = HF->dGetDensityDPres(.5*(p1+p2));
1116 
1117  doublereal qq1 = .75*q1+.25*q2;
1118  doublereal qq2 = .25*q1+.75*q2;
1119 
1120  doublereal dd1 = .5*(density1+density0);
1121  doublereal dd2 = .5*(density0+density2);
1122 
1123  doublereal dLoss11 = 0.;
1124  doublereal dLoss12 = 0.;
1125  doublereal dLoss21 = 0.;
1126  doublereal dLoss22 = 0.;
1127 
1128  if ((Re < HF->dGetRe(HydraulicFluid::LOWER)) || ((turbulent == 0)
1129  && (Re < 1.25*HF->dGetRe(HydraulicFluid::LOWER)))) {
1130  /* laminar, or ascending transition ascendente (continuation) */
1131  doublereal dk = dKlam*viscosity*dCoef;
1132 
1133  dLoss11 = .75*dk/dd1;
1134  dLoss12 = .25*dk/dd1;
1135  dLoss21 = .25*dk/dd2;
1136  dLoss22 = .75*dk/dd2;
1137  } else if ((Re > HF->dGetRe(HydraulicFluid::UPPER)) || ((turbulent == 1)
1138  && (Re > .775*HF->dGetRe(HydraulicFluid::UPPER)))) {
1139  /* turbulent, or descending transition (continuation) */
1140 
1141  doublereal dk = dKtrb*1.75*pow(viscosity, .25)*dCoef;
1142  doublereal dl1 = dk*pow(fabs(qq1), .75)/dd1;
1143  doublereal dl2 = dk*pow(fabs(qq2), .75)/dd2;
1144 
1145  dLoss11 = .75*dl1;
1146  dLoss12 = .25*dl1;
1147  dLoss21 = .25*dl2;
1148  dLoss22 = .75*dl2;
1149  } else {
1150  /* transition */
1152  doublereal dva2 = dva*dva;
1153  doublereal dva3 = dva2*dva;
1154 
1155  doublereal a, b, c, d;
1156 
1157  if (turbulent == 0) {
1158  /* ascending */
1159  a = 7.e-13*dva3;
1160  b = 8.e-10*dva2;
1161  c = -1.8e-5*dva;
1162  d = .0542;
1163  } else /* if (turbulent == 1) */ {
1164  /* descending */
1165  a = 9.e-13*dva3;
1166  b = 2.e-9*dva2;
1167  c = -1.8e-5*dva;
1168  d = .0528;
1169  }
1170 
1171  doublereal fqq1 = fabs(qq1);
1172  doublereal fqq2 = fabs(qq2);
1173 
1174  doublereal fax1 = (((5.*a*fqq1+4.*b)*fqq1+3.*c)*fqq1+2.*d)*fqq1;
1175  doublereal fax2 = (((5.*a*fqq2+4.*b)*fqq2+3.*c)*fqq2+2.*d)*fqq2;
1176 
1177  doublereal dk = dKtrb*dCoef;
1178 
1179  doublereal dl1 = dk*fax1/dd1;
1180  doublereal dl2 = dk*fax2/dd2;
1181 
1182  dLoss11 = .75*dl1;
1183  dLoss12 = .25*dl1;
1184  dLoss21 = .25*dl2;
1185  dLoss22 = .75*dl2;
1186  }
1187 
1188  /* primo blocco: conservazione massa */
1189  doublereal dr = .5*dCoef;
1190  WM.PutCoef(1, 5, -dr);
1191  WM.PutCoef(1, 6, -dr);
1192  WM.PutCoef(2, 5, dr);
1193  WM.PutCoef(2, 6, dr);
1194 
1195  dr = area*length/8.;
1196  WM.PutCoef(1, 3, -dr*3.*densityDPres1);
1197  WM.PutCoef(1, 4, -dr*densityDPres1);
1198  WM.PutCoef(2, 3, -dr*densityDPres2);
1199  WM.PutCoef(2, 4, -dr*3.*densityDPres2);
1200 
1201 
1202  /* secondo blocco: equazione quantita' di moto */
1203  dr = .5*dCoef*area;
1204  doublereal q12 = .5*(q1+q2);
1205  doublereal ddq12 = .5*(q12*q12)/(density0*density0*area)*dRDP0*dCoef;
1206  doublereal ddq1 = q1*q1/(density1*density1*area)*dRDP1*dCoef;
1207  doublereal ddq2 = q2*q2/(density2*density2*area)*dRDP2*dCoef;
1208  WM.PutCoef(3, 3, -dr + ddq1 - ddq12);
1209  WM.PutCoef(3, 4, dr - ddq12);
1210  WM.PutCoef(4, 3, -dr + ddq12);
1211  WM.PutCoef(4, 4, dr + ddq12 - ddq2);
1212 
1213  /* manca la viscosita' */
1214  dr = length/8.;
1215  doublereal dq12 = .5*(q1+q2)/density0;
1216  WM.PutCoef(3, 5, 3.*dr+(dq12-2.*q1/density1)/area*dCoef + dLoss11);
1217  WM.PutCoef(3, 6, dr+dq12/area*dCoef + dLoss12);
1218  WM.PutCoef(4, 5, dr-dq12/area*dCoef + dLoss21);
1219  WM.PutCoef(4, 6, 3.*dr+(2.*q2/density2-dq12)/area*dCoef + dLoss22);
1220 
1221  /* terzo blocco: definizione delle pressioni nodali interne */
1222  WM.PutCoef(5, 1, -1.);
1223  WM.PutCoef(6, 2, -1.);
1224 
1225  WM.PutCoef(5, 3, dCoef);
1226  WM.PutCoef(6, 4, dCoef);
1227 
1228  return WorkMat;
1229 }
const PressureNode * pNode1
Definition: pipe.h:203
void PutColIndex(integer iSubCol, integer iCol)
Definition: submat.h:325
doublereal q2
Definition: pipe.h:221
doublereal dKtrb
Definition: pipe.h:234
GradientExpression< BinaryExpr< FuncPow, LhsExpr, RhsExpr > > pow(const GradientExpression< LhsExpr > &u, const GradientExpression< RhsExpr > &v)
Definition: gradient.h:2961
virtual doublereal dGetRe(Re which)
Definition: hfluid.h:95
FullSubMatrixHandler & SetFull(void)
Definition: submat.h:1168
virtual doublereal dGetDensityDPres(void) const =0
void PutCoef(integer iRow, integer iCol, const doublereal &dCoef)
Definition: submat.h:672
doublereal q1
Definition: pipe.h:220
doublereal density1
Definition: pipe.h:225
doublereal length
Definition: pipe.h:208
doublereal diameter
Definition: pipe.h:206
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
Definition: gradient.h:2973
doublereal densityDPres1
Definition: pipe.h:228
doublereal Re
Definition: pipe.h:213
HydraulicFluid * HF
Definition: preselem.h:79
doublereal dKlam
Definition: pipe.h:233
const PressureNode * pNode2
Definition: pipe.h:204
doublereal densityDPres2
Definition: pipe.h:229
virtual integer iGetFirstRowIndex(void) const
Definition: node.cc:82
virtual void ResizeReset(integer, integer)
Definition: submat.cc:182
static std::stack< cleanup * > c
Definition: cleanup.cc:59
doublereal viscosity
Definition: pipe.h:231
flag turbulent
Definition: pipe.h:210
void PutRowIndex(integer iSubRow, integer iRow)
Definition: submat.h:311
doublereal density2
Definition: pipe.h:227
doublereal area
Definition: pipe.h:207
doublereal density0
Definition: pipe.h:226
static const doublereal a
Definition: hfluid_.h:289
doublereal p2
Definition: pipe.h:216
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
doublereal p1
Definition: pipe.h:215
virtual integer iGetFirstColIndex(void) const
Definition: node.cc:88

Here is the call graph for this function:

SubVectorHandler & DynamicPipe::AssRes ( SubVectorHandler WorkVec,
doublereal  dCoef,
const VectorHandler XCurr,
const VectorHandler XPrimeCurr 
)
virtual

Implements Elem.

Definition at line 1233 of file pipe.cc.

References a, area, c, DEBUGCOUT, density0, density1, density2, densityDPres1, densityDPres2, HydraulicFluid::dGetDensity(), HydraulicFluid::dGetDensityDPres(), HydraulicFluid::dGetRe(), HydraulicFluid::dGetViscosity(), ScalarAlgebraicNode::dGetX(), diameter, dKlam, dKtra, dKtrb, grad::fabs(), HydraulicElem::HF, DofOwnerOwner::iGetFirstIndex(), Node::iGetFirstRowIndex(), length, HydraulicFluid::LOWER, p0, p1, p1p, p2, p2p, pNode1, pNode2, grad::pow(), SubVectorHandler::PutItem(), q1, q1p, q2, q2p, Re, VectorHandler::Resize(), turbulent, HydraulicFluid::UPPER, and viscosity.

1237 {
1238  DEBUGCOUT("Entering DynamicPipe::AssRes()" << std::endl);
1239  WorkVec.Resize(6);
1240 
1241  integer iNode1RowIndex = pNode1->iGetFirstRowIndex()+1;
1242  integer iNode2RowIndex = pNode2->iGetFirstRowIndex()+1;
1243 
1244  doublereal pn1 = pNode1->dGetX();
1245  doublereal pn2 = pNode2->dGetX();
1246 
1247  integer iFirstIndex = iGetFirstIndex();
1248 
1249  p1 = XCurr(iFirstIndex+1); /* pressione */
1250  p2 = XCurr(iFirstIndex+2); /* pressione */
1251  p1p = XPrimeCurr(iFirstIndex+1); /* derivata pressione */
1252  p2p = XPrimeCurr(iFirstIndex+2); /* derivata pressione */
1253 
1254  q1 = XCurr(iFirstIndex+3); /* portata nodo 1 */
1255  q2 = XCurr(iFirstIndex+4); /* portata nodo 2 */
1256  q1p = XPrimeCurr(iFirstIndex+3); /* derivata portata nodo 1 */
1257  q2p = XPrimeCurr(iFirstIndex+4); /* derivata portata nodo 2 */
1258 
1259  doublereal p0 = .5*(p1+p2);
1260 
1261  density1 = HF->dGetDensity(p1); /* densita' all'inizio del tubo */
1262  density2 = HF->dGetDensity(p2); /* densita' alla fine del nodo */
1263  density0 = HF->dGetDensity(p0); /* densita' a meta' tubo */
1264 
1265  /* viscosity = HF->dGetViscosity(); */
1266  densityDPres1 = HF->dGetDensityDPres(.75*p1+.25*p2);
1267  densityDPres2 = HF->dGetDensityDPres(.25*p1+.75*p2);
1268 
1269  viscosity = HF->dGetViscosity(p0);
1270 
1271  doublereal qq1 = .75*q1+.25*q2;
1272  doublereal qq2 = .25*q1+.75*q2;
1273 
1274  doublereal dd1 = .5*(density1+density0);
1275  doublereal dd2 = .5*(density0+density2);
1276 
1277  doublereal q12 = .5*(q1+q2);
1278 
1279  /* determines whether the flow will be turbulent or laminar */
1280  Re = fabs(q12)/area*diameter/viscosity;
1281 
1282  doublereal dLoss1 = 0.;
1283  doublereal dLoss2 = 0.;
1284 
1285  if ((Re < HF->dGetRe(HydraulicFluid::LOWER)) || ((turbulent == 0)
1286  && (Re < 1.25*HF->dGetRe(HydraulicFluid::LOWER)))) {
1287  /* laminar, or ascending transition (continuation) */
1288  doublereal dk = dKlam*viscosity;
1289 
1290  dLoss1 = dk*qq1/dd1;
1291  dLoss2 = dk*qq2/dd2;
1292  } else if ((Re > HF->dGetRe(HydraulicFluid::UPPER)) || ((turbulent == 1)
1293  && (Re > .775*HF->dGetRe(HydraulicFluid::UPPER)))) {
1294  /* turbulent, or descending transition (continuation) */
1295  doublereal dk = dKtrb*pow(viscosity, .25);
1296 
1297  dLoss1 = dk*qq1*pow(fabs(qq1), .75)/dd1;
1298  dLoss2 = dk*qq2*pow(fabs(qq2), .75)/dd2;
1299  } else {
1300  /* transition */
1302  doublereal dva2 = dva*dva;
1303  doublereal dva3 = dva2*dva;
1304 
1305  doublereal a, b, c, d;
1306 
1307  if (turbulent == 0) {
1308  /* ascending */
1309  a = 7.e-13*dva3;
1310  b = 8.e-10*dva2;
1311  c = -1.8e-5*dva;
1312  d = .0542;
1313  } else /* if (turbulent == 1) */ {
1314  /* descending */
1315  a = 9.e-13*dva3;
1316  b = 2.e-9*dva2;
1317  c = -1.8e-5*dva;
1318  d = .0528;
1319  }
1320 
1321  doublereal fqq1 = fabs(qq1);
1322  doublereal fqq2 = fabs(qq2);
1323 
1324  doublereal fax1 = qq1*(((a*fqq1+b)*fqq1+c)*fqq1+d)*fqq1;
1325  doublereal fax2 = qq2*(((a*fqq2+b)*fqq2+c)*fqq2+d)*fqq2;
1326 
1327  dLoss1 = dKtra*fax1/dd1;
1328  dLoss2 = dKtra*fax2/dd2;
1329  }
1330 
1331  /* mass conservation */
1332  doublereal dr = area*length/8.;
1333  WorkVec.PutItem(1, iNode1RowIndex , q12+dr*densityDPres1*(3.*p1p+p2p));
1334  WorkVec.PutItem(2, iNode2RowIndex , -q12+dr*densityDPres2*(p1p+3.*p2p));
1335 
1336  /* momentum balance */
1337  doublereal dp = .5*area*(p2-p1);
1338  doublereal dq12 = q12*q12/(density0*area);
1339  dr = length/8.;
1340  WorkVec.PutItem(3, iFirstIndex+1,
1341  -dr*(3.*q1p+q2p)-dq12+q1*q1/(density1*area)-dp-dLoss1);
1342  WorkVec.PutItem(4, iFirstIndex+2,
1343  -dr*(q1p+3.*q2p)-q2*q2/(density2*area)+dq12-dp-dLoss2);
1344 
1345  /* differential pressure definition */
1346  WorkVec.PutItem(5, iFirstIndex+3, pn1-p1);
1347  WorkVec.PutItem(6, iFirstIndex+4, pn2-p2);
1348 
1349  return WorkVec;
1350 }
const PressureNode * pNode1
Definition: pipe.h:203
doublereal p2p
Definition: pipe.h:218
doublereal q2
Definition: pipe.h:221
doublereal q2p
Definition: pipe.h:223
doublereal dKtrb
Definition: pipe.h:234
GradientExpression< BinaryExpr< FuncPow, LhsExpr, RhsExpr > > pow(const GradientExpression< LhsExpr > &u, const GradientExpression< RhsExpr > &v)
Definition: gradient.h:2961
virtual doublereal dGetRe(Re which)
Definition: hfluid.h:95
virtual doublereal dGetDensityDPres(void) const =0
doublereal p1p
Definition: pipe.h:217
static double * p0
doublereal q1
Definition: pipe.h:220
doublereal density1
Definition: pipe.h:225
doublereal length
Definition: pipe.h:208
doublereal diameter
Definition: pipe.h:206
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
Definition: gradient.h:2973
virtual void PutItem(integer iSubRow, integer iRow, const doublereal &dCoef)
Definition: submat.h:1445
doublereal densityDPres1
Definition: pipe.h:228
virtual doublereal dGetDensity(void) const =0
virtual const doublereal & dGetX(void) const
Definition: node.h:492
doublereal Re
Definition: pipe.h:213
doublereal q1p
Definition: pipe.h:222
HydraulicFluid * HF
Definition: preselem.h:79
doublereal dKtra
Definition: pipe.h:235
doublereal dKlam
Definition: pipe.h:233
const PressureNode * pNode2
Definition: pipe.h:204
doublereal densityDPres2
Definition: pipe.h:229
#define DEBUGCOUT(msg)
Definition: myassert.h:232
virtual integer iGetFirstRowIndex(void) const
Definition: node.cc:82
virtual doublereal dGetViscosity(void) const =0
static std::stack< cleanup * > c
Definition: cleanup.cc:59
doublereal viscosity
Definition: pipe.h:231
flag turbulent
Definition: pipe.h:210
doublereal density2
Definition: pipe.h:227
doublereal area
Definition: pipe.h:207
doublereal density0
Definition: pipe.h:226
static const doublereal a
Definition: hfluid_.h:289
doublereal p2
Definition: pipe.h:216
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
doublereal p1
Definition: pipe.h:215
virtual void Resize(integer iNewSize)=0

Here is the call graph for this function:

virtual void DynamicPipe::GetConnectedNodes ( std::vector< const Node * > &  connectedNodes) const
inlinevirtual

Reimplemented from Elem.

Definition at line 279 of file pipe.h.

References pNode1, and pNode2.

279  {
280  connectedNodes.resize(2);
281  connectedNodes[0] = pNode1;
282  connectedNodes[1] = pNode2;
283  };
const PressureNode * pNode1
Definition: pipe.h:203
const PressureNode * pNode2
Definition: pipe.h:204
DofOrder::Order DynamicPipe::GetDofType ( unsigned int  i) const
virtual

Reimplemented from Elem.

Definition at line 1063 of file pipe.cc.

References ASSERT, and DofOrder::DIFFERENTIAL.

1064 {
1065  ASSERT(i >= 0 && i < 4);
1066  return DofOrder::DIFFERENTIAL;
1067 }
#define ASSERT(expression)
Definition: colamd.c:977
DofOrder::Order DynamicPipe::GetEqType ( unsigned int  i) const
virtual

Reimplemented from SimulationEntity.

Definition at line 1070 of file pipe.cc.

References ASSERT, and DofOrder::DIFFERENTIAL.

1071 {
1072  ASSERT(i >= 0 && i < 4);
1073  return DofOrder::DIFFERENTIAL;
1074 }
#define ASSERT(expression)
Definition: colamd.c:977
HydraulicElem::Type DynamicPipe::GetHydraulicType ( void  ) const
virtual

Implements HydraulicElem.

Definition at line 1047 of file pipe.cc.

References HydraulicElem::DYNAMIC_PIPE.

1047  {
1049 }
unsigned int DynamicPipe::iGetNumDof ( void  ) const
virtual

Reimplemented from Elem.

Definition at line 1057 of file pipe.cc.

1058 {
1059  return 4;
1060 }
void DynamicPipe::Output ( OutputHandler OH) const
virtual

Reimplemented from ToBeOutput.

Definition at line 1367 of file pipe.cc.

References ToBeOutput::bToBeOutput(), density0, density1, density2, densityDPres1, densityDPres2, WithLabel::GetLabel(), OutputHandler::Hydraulic(), p1, p1p, p2, p2p, q1, q1p, q2, q2p, Re, and turbulent.

1368 {
1369  if (bToBeOutput()) {
1370  std::ostream& out = OH.Hydraulic();
1371  out
1372  << std::setw(8) << GetLabel() /* 1 */
1373  << " " << p1 /* 2 */
1374  << " " << p2 /* 3 */
1375  << " " << p1p /* 4 */
1376  << " " << p2p /* 5 */
1377  << " " << q1 /* 6 */
1378  << " " << q2 /* 7 */
1379  << " " << q1p /* 8 */
1380  << " " << q2p /* 9 */
1381  << " " << density1 /* 10 */
1382  << " " << density0 /* 11 */
1383  << " " << density2 /* 12 */
1384  << " " << densityDPres1 /* 13 */
1385  << " " << densityDPres2 /* 14 */
1386  << " " << Re /* 15 */
1387  << " " << turbulent /* 16 */
1388  << std::endl;
1389  }
1390 }
doublereal p2p
Definition: pipe.h:218
doublereal q2
Definition: pipe.h:221
doublereal q2p
Definition: pipe.h:223
virtual bool bToBeOutput(void) const
Definition: output.cc:890
doublereal p1p
Definition: pipe.h:217
doublereal q1
Definition: pipe.h:220
doublereal density1
Definition: pipe.h:225
doublereal densityDPres1
Definition: pipe.h:228
doublereal Re
Definition: pipe.h:213
doublereal q1p
Definition: pipe.h:222
doublereal densityDPres2
Definition: pipe.h:229
flag turbulent
Definition: pipe.h:210
doublereal density2
Definition: pipe.h:227
doublereal density0
Definition: pipe.h:226
std::ostream & Hydraulic(void) const
Definition: output.h:492
doublereal p2
Definition: pipe.h:216
unsigned int GetLabel(void) const
Definition: withlab.cc:62
doublereal p1
Definition: pipe.h:215

Here is the call graph for this function:

std::ostream & DynamicPipe::Restart ( std::ostream &  out) const
virtual

Implements Elem.

Definition at line 1052 of file pipe.cc.

1053 {
1054  return out << "Pipe not implemented yet!" << std::endl;
1055 }
void DynamicPipe::SetValue ( DataManager pDM,
VectorHandler X,
VectorHandler XP,
SimulationEntity::Hints ph = 0 
)
virtual

Reimplemented from SimulationEntity.

Definition at line 1393 of file pipe.cc.

References ScalarAlgebraicNode::dGetX(), DofOwnerOwner::iGetFirstIndex(), p1, p2, pNode1, pNode2, VectorHandler::PutCoef(), and q0.

1396 {
1397  integer i = iGetFirstIndex();
1398 
1399  doublereal p1 = pNode1->dGetX();
1400  doublereal p2 = pNode2->dGetX();
1401 
1402  X.PutCoef(i+1, p1);
1403  X.PutCoef(i+2, p2);
1404  X.PutCoef(i+3, q0);
1405  X.PutCoef(i+4, -q0);
1406 
1407  XP.PutCoef(i+1, 0.);
1408  XP.PutCoef(i+2, 0.);
1409  XP.PutCoef(i+3, 0.);
1410  XP.PutCoef(i+4, 0.);
1411 }
const PressureNode * pNode1
Definition: pipe.h:203
doublereal q0
Definition: pipe.h:211
virtual const doublereal & dGetX(void) const
Definition: node.h:492
const PressureNode * pNode2
Definition: pipe.h:204
virtual void PutCoef(integer iRow, const doublereal &dCoef)=0
doublereal p2
Definition: pipe.h:216
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
doublereal p1
Definition: pipe.h:215

Here is the call graph for this function:

void DynamicPipe::WorkSpaceDim ( integer piNumRows,
integer piNumCols 
) const
virtual

Implements Elem.

Definition at line 1077 of file pipe.cc.

1078 {
1079  *piNumRows = 6;
1080  *piNumCols = 6;
1081 }

Member Data Documentation

doublereal DynamicPipe::area
private

Definition at line 207 of file pipe.h.

Referenced by AssJac(), AssRes(), and DynamicPipe().

doublereal DynamicPipe::density0
private

Definition at line 226 of file pipe.h.

Referenced by AssJac(), AssRes(), and Output().

doublereal DynamicPipe::density1
private

Definition at line 225 of file pipe.h.

Referenced by AssJac(), AssRes(), and Output().

doublereal DynamicPipe::density2
private

Definition at line 227 of file pipe.h.

Referenced by AssJac(), AssRes(), and Output().

doublereal DynamicPipe::densityDPres1
private

Definition at line 228 of file pipe.h.

Referenced by AssJac(), AssRes(), and Output().

doublereal DynamicPipe::densityDPres2
private

Definition at line 229 of file pipe.h.

Referenced by AssJac(), AssRes(), and Output().

doublereal DynamicPipe::diameter
private

Definition at line 206 of file pipe.h.

Referenced by AssJac(), AssRes(), and DynamicPipe().

doublereal DynamicPipe::dKlam
private

Definition at line 233 of file pipe.h.

Referenced by AssJac(), AssRes(), and DynamicPipe().

doublereal DynamicPipe::dKtra
private

Definition at line 235 of file pipe.h.

Referenced by AssRes(), and DynamicPipe().

doublereal DynamicPipe::dKtrb
private

Definition at line 234 of file pipe.h.

Referenced by AssJac(), AssRes(), and DynamicPipe().

doublereal DynamicPipe::length
private

Definition at line 208 of file pipe.h.

Referenced by AssJac(), AssRes(), and DynamicPipe().

doublereal DynamicPipe::p1
private

Definition at line 215 of file pipe.h.

Referenced by AssJac(), AssRes(), Output(), and SetValue().

doublereal DynamicPipe::p1p
private

Definition at line 217 of file pipe.h.

Referenced by AssRes(), and Output().

doublereal DynamicPipe::p2
private

Definition at line 216 of file pipe.h.

Referenced by AssJac(), AssRes(), Output(), and SetValue().

doublereal DynamicPipe::p2p
private

Definition at line 218 of file pipe.h.

Referenced by AssRes(), and Output().

const PressureNode* DynamicPipe::pNode1
private

Definition at line 203 of file pipe.h.

Referenced by AssJac(), AssRes(), DynamicPipe(), GetConnectedNodes(), and SetValue().

const PressureNode* DynamicPipe::pNode2
private

Definition at line 204 of file pipe.h.

Referenced by AssJac(), AssRes(), DynamicPipe(), GetConnectedNodes(), and SetValue().

doublereal DynamicPipe::q0
private

Definition at line 211 of file pipe.h.

Referenced by SetValue().

doublereal DynamicPipe::q1
private

Definition at line 220 of file pipe.h.

Referenced by AssJac(), AssRes(), and Output().

doublereal DynamicPipe::q1p
private

Definition at line 222 of file pipe.h.

Referenced by AssRes(), and Output().

doublereal DynamicPipe::q2
private

Definition at line 221 of file pipe.h.

Referenced by AssJac(), AssRes(), and Output().

doublereal DynamicPipe::q2p
private

Definition at line 223 of file pipe.h.

Referenced by AssRes(), and Output().

doublereal DynamicPipe::Re
private

Definition at line 213 of file pipe.h.

Referenced by AfterConvergence(), AssJac(), AssRes(), and Output().

flag DynamicPipe::turbulent
private

Definition at line 210 of file pipe.h.

Referenced by AfterConvergence(), AssJac(), AssRes(), and Output().

doublereal DynamicPipe::viscosity
private

Definition at line 231 of file pipe.h.

Referenced by AssJac(), and AssRes().


The documentation for this class was generated from the following files: