@@ -95,6 +95,15 @@ double cvOneDBFSolver::convCriteria = 0;
9595BoundCondType cvOneDBFSolver::inletBCtype;
9696int cvOneDBFSolver::ASCII = 1 ;
9797
98+
99+ namespace {
100+
101+ double linearInterpolate (double x, double x1, double y1, double x2, double y2) {
102+ return y1 + (x - x1) * (y2 - y1) / (x2 - x1);
103+ }
104+
105+ } // namespace
106+
98107// SET MODE PTR
99108void cvOneDBFSolver::SetModelPtr (cvOneDModel *mdl){
100109 model = mdl;
@@ -424,7 +433,6 @@ void cvOneDBFSolver::postprocess_VTK_XML3D_ONEFILE(){
424433 cvDoubleVec tmp;
425434 cvDoubleMat segNodeList;
426435 double lengthByNodes = 0.0 ;
427- double lengthBySegment = 0.0 ;
428436 int startOut = 0 ;
429437 int finishOut = 0 ;
430438 double segLength = 0.0 ;
@@ -470,7 +478,6 @@ void cvOneDBFSolver::postprocess_VTK_XML3D_ONEFILE(){
470478 segVers[2 ][0 ] /= mod;
471479
472480 lengthByNodes = mod;
473- lengthBySegment = currSeg->getSegmentLength ();
474481
475482 // Compute Segment Local axis system
476483 evalSegmentLocalAxis (segVers);
@@ -484,8 +491,12 @@ void cvOneDBFSolver::postprocess_VTK_XML3D_ONEFILE(){
484491 currCentre[2 ] = nodeList[inletSegJoint][2 ] + loopEl*lengthByNodes/double (currSeg->getNumElements ())*segVers[2 ][0 ];
485492
486493 // Get initial radius at current location
487- currIniArea = currSeg->getInitInletS () + (loopEl/double (currSeg->getNumElements ()))*(currSeg->getInitOutletS () - currSeg->getInitInletS ());
488- currIniRad = sqrt (currIniArea/M_PI);
494+
495+ // TODO: verify this is the correct "z" location we want
496+ // to interpolate at. These loops and myriad variables make
497+ // something super simple super confusing.
498+ double const zAxial = linearInterpolate (loopEl, 0 , currSeg->getInletZ (), currSeg->getNumElements (), currSeg->getOutletZ ());
499+ currIniRad = currSeg->getInitialRadius (zAxial);
489500
490501 // Loop on the subdivisions
491502 for (int loopSubdiv=0 ;loopSubdiv<circSubdiv;loopSubdiv++){
@@ -559,7 +570,14 @@ void cvOneDBFSolver::postprocess_VTK_XML3D_ONEFILE(){
559570 for (int j=startOut;j<finishOut;j+=2 ){
560571
561572 // Evaluate Initial Area at current location
562- iniArea = currSeg->getInitInletS () + (((j-startOut)/2 )/double (currSeg->getNumElements ()))*(currSeg->getInitOutletS () - currSeg->getInitInletS ());
573+
574+ // TODO: verify this is the correct "z" location we want
575+ // to interpolate at. These loops and myriad variables make
576+ // something super simple super confusing.
577+ double const zAxial = linearInterpolate ((j-startOut)/2.0 ,
578+ startOut, currSeg->getInletZ (), finishOut, currSeg->getOutletZ ());
579+ iniArea = currSeg->getInitialArea (zAxial);
580+
563581 // Eval Current Area at current location
564582 newArea = TotalSolution[loopTime][j];
565583 // Evaluate Radial displacement
@@ -738,7 +756,6 @@ void cvOneDBFSolver::postprocess_VTK_XML3D_MULTIPLEFILES(){
738756 cvDoubleVec tmp;
739757 cvDoubleMat segNodeList;
740758 double lengthByNodes = 0.0 ;
741- double lengthBySegment = 0.0 ;
742759 int startOut = 0 ;
743760 int finishOut = 0 ;
744761 double segLength = 0.0 ;
@@ -812,7 +829,6 @@ void cvOneDBFSolver::postprocess_VTK_XML3D_MULTIPLEFILES(){
812829 segVers[2 ][0 ] /= mod;
813830
814831 lengthByNodes = mod;
815- lengthBySegment = currSeg->getSegmentLength ();
816832
817833 // Compute Segment Local axis system
818834 evalSegmentLocalAxis (segVers);
@@ -826,9 +842,13 @@ void cvOneDBFSolver::postprocess_VTK_XML3D_MULTIPLEFILES(){
826842 currCentre[2 ] = nodeList[inletSegJoint][2 ] + loopEl*lengthByNodes/double (currSeg->getNumElements ())*segVers[2 ][0 ];
827843
828844 // Get initial radius at current location
829- currIniArea = currSeg->getInitInletS () + (loopEl/double (currSeg->getNumElements ()))*(currSeg->getInitOutletS () - currSeg->getInitInletS ());
830- currIniRad = sqrt (currIniArea/M_PI);
831-
845+
846+ // TODO: verify this is the correct "z" location we want
847+ // to interpolate at. These loops and myriad variables make
848+ // something super simple super confusing.
849+ double const zAxial = linearInterpolate (loopEl, 0 , currSeg->getInletZ (), currSeg->getNumElements (), currSeg->getOutletZ ());
850+ currIniRad = currSeg->getInitialRadius (zAxial);
851+
832852 // Loop on the subdivisions
833853 for (int loopSubdiv=0 ;loopSubdiv<circSubdiv;loopSubdiv++){
834854 currTheta = loopSubdiv*2 *M_PI/double (circSubdiv);
@@ -899,7 +919,14 @@ void cvOneDBFSolver::postprocess_VTK_XML3D_MULTIPLEFILES(){
899919 for (int j=startOut;j<finishOut;j+=2 ){
900920
901921 // Evaluate Initial Area at current location
902- iniArea = currSeg->getInitInletS () + (((j-startOut)/2 )/double (currSeg->getNumElements ()))*(currSeg->getInitOutletS () - currSeg->getInitInletS ());
922+
923+ // TODO: verify this is the correct "z" location we want
924+ // to interpolate at. These loops and myriad variables make
925+ // something super simple super confusing.
926+ double const zAxial = linearInterpolate ((j-startOut)/2.0 ,
927+ startOut, currSeg->getInletZ (), finishOut, currSeg->getOutletZ ());
928+ iniArea = currSeg->getInitialArea (zAxial);
929+
903930 // Eval Current Area at current location
904931 newArea = TotalSolution[loopTime][j];
905932 // Evaluate Radial displacement
@@ -1124,19 +1151,15 @@ void cvOneDBFSolver::QuerryModelInformation(void)
11241151 for (i=0 ; i<is; i++){
11251152 cvOneDSegment* seg = model->getSegment (i);
11261153 long nels = seg->getNumElements ();
1127- double segLen = seg->getSegmentLength ();
11281154 int matID = seg->getMaterialID ();
11291155 MeshType mType = seg->getMeshType ();
1130- double zin = seg->getInletZ ();
1131- double zout = seg->getOutletZ ();
11321156
11331157 cvOneDSubdomain* subdomain = new cvOneDSubdomain;
11341158 assert (subdomain != 0 );
11351159 subdomain -> SetNumberOfNodes (nels+1 );
11361160 subdomain -> SetNumberOfElements (nels);
11371161 subdomain -> SetMeshType (mType );
1138- subdomain -> Init (zin, zout);
1139-
1162+ subdomain -> Init (seg->getSpatialCharacteristics ());
11401163
11411164 // Get the Initial Properties of the subdomain...
11421165 double Qo = 0.0 ;
@@ -1147,17 +1170,13 @@ void cvOneDBFSolver::QuerryModelInformation(void)
11471170 P0 = seg->getInitialPressure ();
11481171 dQ0_dT = 0.0 ;
11491172 }
1150- double So = seg->getInitInletS ();
1151- double Sn = seg->getInitOutletS ();
11521173 BoundCondType boundT = seg -> getBoundCondition ();
11531174 double boundV= seg -> getBoundValue ();
11541175
11551176 // Set these in the subdomain.
11561177 subdomain->SetInitialFlow (Qo);
11571178 subdomain->SetInitialdFlowdT (dQ0_dT);
1158- subdomain->SetInitInletS (So);
11591179 subdomain->SetInitialPressure (P0);
1160- subdomain->SetInitOutletS (Sn);
11611180 subdomain->SetGlobal1stNodeID (temp);
11621181 subdomain->SetBoundCondition (boundT);
11631182 if (!seg->IsOutlet ){
@@ -1324,22 +1343,21 @@ void cvOneDBFSolver::CreateGlobalArrays(void){
13241343
13251344// Initialize the solution, that is, area as area input and flow rate as 0 except the inlet
13261345void cvOneDBFSolver::CalcInitProps (long ID){
1327- double segLen = subdomainList[ID] -> GetLength ();
13281346 double Qo, dQ0dT;
1329- Qo = subdomainList[ID] -> GetInitialFlow ();
1347+ auto const & subdomain = subdomainList[ID];
1348+ Qo = subdomain -> GetInitialFlow ();
13301349 dQ0dT=0 ;
13311350
1332- double So = subdomainList[ID] -> GetInitInletS ();
1333- double Sn = subdomainList[ID] -> GetInitOutletS ();
1334- for ( long node = 0 ; node < subdomainList[ID]->GetNumberOfNodes (); node++){
1335- double zn = subdomainList[ID]->GetNodalCoordinate ( node);
1351+ for ( long node = 0 ; node < subdomain->GetNumberOfNodes (); node++){
1352+ double zn = subdomain->GetNodalCoordinate ( node);
13361353 long eqNumbers[2 ];
13371354 mathModels[0 ]->GetNodalEquationNumbers (node, eqNumbers, ID);
13381355
13391356 // Linear Interpolation
1340- double zi = (zn - segLen)/(0.0 -segLen);
1341- double Si = (zi*(So - Sn)) + Sn;
1342- (*previousSolution)[eqNumbers[0 ]] = Si;
1357+ // This is "Si"
1358+ // TODO: verify this calcluation makes sense
1359+ double initialAreaAtZn = getInterpolatedArea (zn, subdomain->getSpatialCharacteristics ());
1360+ (*previousSolution)[eqNumbers[0 ]] = initialAreaAtZn;
13431361
13441362 if (node == 0 ){
13451363 (*previousSolution)[eqNumbers[1 ]] = Qo;
0 commit comments