Skip to content

Commit 4d90ea4

Browse files
committed
Fixed bug in Coronary Outflow boundary condition
1 parent bb4ad03 commit 4d90ea4

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

FEBioFluid/FEFluidCOBC.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ FEFluidCOBC::FEFluidCOBC(FEModel* pfem) : FEPrescribedSurface(pfem), m_dofW(pfem
5858
m_p0 = 0;
5959
m_pd = 0.0;
6060
m_e = 0.0;
61-
61+
m_Pmi = nullptr;
62+
m_PRA = nullptr;
6263
}
6364

6465
//-----------------------------------------------------------------------------
@@ -86,8 +87,7 @@ bool FEFluidCOBC::Init()
8687
if (m_pfluid == nullptr) return false;
8788

8889
m_pn = m_pp = m_ppp = m_p0;
89-
// m_pdn = m_pdp = m_pd;
90-
m_qn = m_qp = m_qpp = 0;
90+
m_q = m_qp = m_qpp = 0;
9191
m_tp = m_tpp = 0;
9292

9393
if (m_Pmi) { if (!m_Pmi->Init()) return false; }
@@ -105,18 +105,19 @@ void FEFluidCOBC::UpdateDilatation()
105105
double time = timeInfo.currentTime;
106106
int iter = timeInfo.currentIteration;
107107
double dt = timeInfo.timeIncrement;
108+
if (dt == 0) return;
108109
if ((time > m_tp) && (iter == 0)) {
109110
m_ppp = m_pp;
110111
m_pp = m_pn;
111112
m_qpp = m_qp;
112-
m_qp = m_qn;
113+
m_qp = m_q;
113114
m_pdp = m_pdn;
114115
m_tpp = m_tp;
115116
m_tp = time;
116117
}
117118

118119
// evaluate the flow rate at the current time
119-
m_qn = FlowRate();
120+
m_q = FlowRate();
120121
m_pdn = m_pd;
121122

122123
double Rve = m_Rv + m_Rvm;
@@ -129,17 +130,23 @@ void FEFluidCOBC::UpdateDilatation()
129130
double dtp = m_tp - m_tpp;
130131

131132
double c0 = tauvi*taua/(dt*dt);
133+
double d0 = (dtp > 0) ? tauvi*taua/(dt*dtp) : 0;
132134
double c1 = m_Ra*c0;
133-
double c2 = (m_Ra*(tauae + tauvi)+m_Ram*tauvi)/dt;
135+
double d1 = m_Ra*d0;
136+
double d2 = (tauvi+tauae)/dt;
137+
double c3 = tauvi/dt;
138+
double c2 = m_Ra*d2 + m_Ram*c3;
134139
double a = c1 + c2 + Rt;
135-
double b = (c1+c2)*m_qp + m_Ra*tauvi*taua/dt/dtp*(m_qp-m_qpp);
136-
double c = c0 + (tauvi+tauae)/dt + 1;
137-
double d = c0*m_pp + tauvi*taua/dt/dtp*(m_pp - m_ppp) + (tauvi+tauae)/dt*m_pp;
138-
if (m_PRA) d += m_PRA->value(time);
140+
double b = (c1+c2+d1)*m_qp;
141+
b -= (dtp > 0) ? d1*m_qpp : 0;
142+
double c = c0 + d2 + 1;
143+
double d = (c0 + d0 + d2)*m_pp;
144+
d -= (dtp > 0) ? d0*m_ppp : 0;
145+
if (m_PRA) d += (m_PRA) ? m_PRA->value(time) : 0;
139146
if (m_Pmi) d += tauvi*m_Pmi->derive(time);
140147

141148
// calculate the RCR pressure
142-
m_pn = (a*m_qn + d - b)/c;
149+
m_pn = (a*m_q + d - b)/c;
143150

144151
// calculate the dilatation
145152
m_e = 0.0;
@@ -247,7 +254,7 @@ void FEFluidCOBC::CopyFrom(FEBoundaryCondition* pbc)
247254
void FEFluidCOBC::Serialize(DumpStream& ar)
248255
{
249256
FEPrescribedSurface::Serialize(ar);
250-
ar & m_pn & m_pp & m_pp & m_qn & m_qp & m_qpp & m_tp & m_tpp & m_e;
257+
ar & m_pn & m_pp & m_pp & m_q & m_qp & m_qpp & m_tp & m_tpp & m_e;
251258
if (ar.IsShallow()) return;
252259
ar & m_pfluid;
253260
ar & m_dofW & m_dofEF;

FEBioFluid/FEFluidCOBC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class FEBIOFLUID_API FEFluidCOBC : public FEPrescribedSurface
8080
double m_pn; //!< fluid pressure at current time point
8181
double m_pp; //!< fluid pressure at previous time point
8282
double m_ppp; //!< fluid pressure at 2nd-previous time point
83-
double m_qn; //!< flow rate at current time point
83+
double m_q; //!< flow rate at current time point
8484
double m_qp; //!< flow rate at previous time point
8585
double m_qpp; //!< flow rate at 2nd-previous time point
8686
double m_pdn; //!< downstream fluid pressure at current time point

0 commit comments

Comments
 (0)