# 1 "/home/admin/SimulationCore2/TorqueDrag/TD_DrillingSubs/MeshGeneration_FluidModule.f90" subroutine MeshGeneration_FluidModule Use TD_DrillStemComponents use SimulationVariables !@ use SimulationVariables !@ Use TD_StringConnectionData Use GeoElements_FluidModule use CPumpsVariables use CPumps Use CStringConfigurationVariables Use CBopStackVariables !use ConfigurationVariables !@ , only: Drawworks implicit none Integer :: ii , jj , semijj , kk , k , m , s Integer :: ElementsCount , StringConfigCount REAL(8) :: mm , nn , dl , StartAngle , EndAngle REAL(8) :: A(30) !?????????10 REAL(8) :: TD_ElementLength A = 0.d0 A(1) = data%Configuration%BopStack%AboveAnnularHeight ! WellHead[ft] jj = 1 !==================================================== ! Mesh Generation of DrillStem Components !==================================================== !data%State%TD_String%StringConfigurationCount = StringConfigurationCount !??????????? StringConfigCount = data%State%TD_String%StringConfigurationCount if (allocated(data%State%F_String)) Deallocate(data%State%F_String) if (data%State%TD_DrillStem(1)%ComponentType==0) then Allocate (data%State%F_String(StringConfigCount-1)) else Allocate (data%State%F_String(StringConfigCount)) end if if (data%State%TD_DrillStem(1)%ComponentType==0) then ElementsCount = 1 Do ii=1,(StringConfigCount-1) data%State%F_String(ii)%ID = data%State%TD_DrillStem(ii+1)%Id*12.d0 ![inch] data%State%F_String(ii)%OD = data%State%TD_DrillStem(ii+1)%Od*12.d0 ![inch] data%State%F_String(ii)%FirstElement = ElementsCount+1 data%State%F_String(ii)%LastElement = data%State%F_String(ii)%FirstElement+(data%State%TD_DrillStem(ii+1)%Numbs-1) data%State%F_String(ii)%ElType = data%State%TD_DrillStem(ii+1)%ComponentType ElementsCount = data%State%F_String(ii)%LastElement End Do StringConfigCount = StringConfigCount-1 else ElementsCount = 0 Do ii=1,StringConfigCount data%State%F_String(ii)%ID = data%State%TD_DrillStem(ii)%Id*12.d0 ![inch] data%State%F_String(ii)%OD = data%State%TD_DrillStem(ii)%Od*12.d0 ![inch] data%State%F_String(ii)%FirstElement = ElementsCount+1 data%State%F_String(ii)%LastElement = data%State%F_String(ii)%FirstElement+(data%State%TD_DrillStem(ii)%Numbs-1) data%State%F_String(ii)%ElType = data%State%TD_DrillStem(ii)%ComponentType ElementsCount = data%State%F_String(ii)%LastElement End Do end if Do ii=1,StringConfigCount data%State%F_String(ii)%TopDepth = data%State%TD_DrillStems(data%State%F_String(ii)%LastElement)%TopDepthIni ![ft] data%State%F_String(ii)%DownDepth = data%State%TD_DrillStems(data%State%F_String(ii)%FirstElement)%DownDepthIni ![ft] if (data%State%F_String(ii)%DownDepth>A(1)) then jj = jj+1 A(jj) = data%State%F_String(ii)%DownDepth end if End Do !=========> Removed Volume Calculation in DrillStem TD_ElementLength = data%State%F_String(StringConfigCount)%DownDepth-data%State%F_String(StringConfigCount)%TopDepth if ( StringConfigCount==data%State%TD_Vol%PreCount ) then if ( data%State%TD_Vol%PreElementLength>TD_ElementLength ) then data%State%TD_Vol%RemoveVolume = (data%State%TD_Vol%PreElementLength-TD_ElementLength)*((pi*((data%State%F_String(StringConfigCount)%ID/12.d0)**2))/4.d0) ![ft^3] else data%State%TD_Vol%RemoveVolume = 0.d0 end if else if ( StringConfigCount Out of Well Intervals data%State%F_Interval(1)%StartTVD = 0.0d0 !?????????????? data%State%F_Interval(1)%EndTVD = -data%State%TD_StConn%ConnectionHeight data%State%F_Interval(1)%StartAngle = 0.d0 !??????????????????????? data%State%F_Interval(1)%EndAngle = 0.d0 !??????????????????????? data%State%F_Counts%OutOfWellIntervalCounts = 1 Do ii= 2 , StringConfigCount+1 if ( data%State%F_Interval(ii)%StartDepth<=0.d0 ) then data%State%F_Interval(ii)%StartTVD = data%State%F_Interval(ii)%StartDepth data%State%F_Interval(ii)%StartAngle = 0.0d0 end if if ( data%State%F_Interval(ii)%EndDepth<=0.d0 ) then data%State%F_Interval(ii)%EndTVD = data%State%F_Interval(ii)%EndDepth data%State%F_Interval(ii)%EndAngle = 0.0d0 data%State%F_Counts%OutOfWellIntervalCounts = data%State%F_Counts%OutOfWellIntervalCounts+1 end if End Do !=========> if (allocated(data%State%TDGeo%TVD)) Deallocate(data%State%TDGeo%TVD) Allocate (data%State%TDGeo%TVD(jj)) if (allocated(data%State%TDGeo%Angle)) Deallocate(data%State%TDGeo%Angle) Allocate (data%State%TDGeo%Angle(jj)) data%State%TDGeo%TVD(1) = data%State%TD_WellGeneral%WellTotalVerticalLength !????? !print*, 'data%State%TD_WellGeneral%WellTotalVerticalLength=' ,data%State%TD_WellGeneral%WellTotalVerticalLength data%State%TDGeo%TVD(jj) = data%Configuration%BopStack%AboveAnnularHeight ! WellHead[ft] !0.d0 ???????????????? k = 1 mm = 0.d0 nn = 0.d0 EndAngle = data%State%TD_WellGeo(1)%StartAngle !??????????????? data%State%TDGeo%Angle(jj) = EndAngle Do ii = jj-1,1,-1 !???1or2 do kk = k, data%State%TD_WellGeneral%WellIntervalsCount StartAngle = EndAngle if ( data%State%TDGeo%MD(ii)>data%State%TD_WellGeo(kk)%TopDepth ) then if ( data%State%TDGeo%MD(ii)>data%State%TD_WellGeo(kk)%DownDepth ) then dl = data%State%TD_WellGeo(kk)%DownDepth-nn ![ft] nn = data%State%TD_WellGeo(kk)%DownDepth if ( data%State%TD_WellGeo(kk)%HoleType==0 ) then EndAngle = StartAngle !print*, 'StartAngle1=' ,ii , kk, StartAngle !print*, 'EndAngle1=' ,ii , kk, EndAngle data%State%TDGeo%TVD(ii) = mm+(dl*cos(data%State%TD_WellGeo(kk)%StartAngle)) ![ft] data%State%TDGeo%Angle(ii) = EndAngle !print*, 'data%State%TDGeo%TVD(ii)1=' ,ii , kk, data%State%TDGeo%TVD(ii) else if ( data%State%TD_WellGeo(kk)%HoleType==1 ) then EndAngle = StartAngle+(dl/data%State%TD_WellGeo(kk)%RCurvature) !????????????????? !print*, 'StartAngle2=' ,ii , kk, StartAngle !print*, 'EndAngle2=' ,ii , kk, EndAngle data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))*cos(abs(StartAngle)))-(data%State%TD_WellGeo(kk)%RCurvature*(1.-cos(abs(EndAngle)-abs(StartAngle)))*sin(abs(StartAngle))) !data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) data%State%TDGeo%Angle(ii) = EndAngle !print*, 'data%State%TDGeo%TVD(ii)2=' , ii , kk, data%State%TDGeo%TVD(ii) else if ( data%State%TD_WellGeo(kk)%HoleType==2 ) then EndAngle = StartAngle-(dl/data%State%TD_WellGeo(kk)%RCurvature) !????????????????? !print*, 'StartAngle22=' ,ii , kk, StartAngle !print*, 'EndAngle22=' ,ii , kk, EndAngle data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(data%State%TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) !data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) data%State%TDGeo%Angle(ii) = EndAngle !print*, 'data%State%TDGeo%TVD(ii)22=' , ii , kk, data%State%TDGeo%TVD(ii) end if mm = data%State%TDGeo%TVD(ii) else dl = data%State%TDGeo%MD(ii)-nn nn = data%State%TDGeo%MD(ii) if ( data%State%TD_WellGeo(kk)%HoleType==0 ) then EndAngle = StartAngle !print*, 'StartAngle3=' ,ii , kk, StartAngle !print*, 'EndAngle3=' ,ii , kk, EndAngle data%State%TDGeo%TVD(ii) = mm+(dl*cos(data%State%TD_WellGeo(kk)%StartAngle)) data%State%TDGeo%Angle(ii) = EndAngle !print*, 'data%State%TDGeo%TVD(ii)3=' ,ii , kk, data%State%TDGeo%TVD(ii) else if ( data%State%TD_WellGeo(kk)%HoleType==1 ) then EndAngle = StartAngle+(dl/data%State%TD_WellGeo(kk)%RCurvature) !??????????????????? !print*, 'StartAngle4=' ,ii , kk, StartAngle !print*, 'EndAngle4=' ,ii , kk, EndAngle data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))*cos(abs(StartAngle)))-(data%State%TD_WellGeo(kk)%RCurvature*(1.-cos(abs(EndAngle)-abs(StartAngle)))*sin(abs(StartAngle))) data%State%TDGeo%Angle(ii) = EndAngle !data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) !print*, 'mm=' ,mm !print*, 'data%State%TDGeo%TVD(ii)4=' ,ii , kk, data%State%TDGeo%TVD(ii) else if ( data%State%TD_WellGeo(kk)%HoleType==2 ) then EndAngle = StartAngle-(dl/data%State%TD_WellGeo(kk)%RCurvature) !??????????????????? !print*, 'StartAngle44=' ,ii , kk, StartAngle !print*, 'EndAngle44=' ,ii , kk, EndAngle data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(data%State%TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) data%State%TDGeo%Angle(ii) = EndAngle !data%State%TDGeo%TVD(ii) = mm+(data%State%TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) !print*, 'mm=' ,mm , (data%State%TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(data%State%TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) !print*, 'data%State%TDGeo%TVD(ii)44=' ,ii , kk, data%State%TDGeo%TVD(ii) end if mm = data%State%TDGeo%TVD(ii) k = kk exit end if end if end do End Do !if (data%State%F_Counts%OutOfWellIntervalCounts==1) then ! s = 2 !else ! s = data%State%F_Counts%OutOfWellIntervalCounts !end if ! Do ii = (data%State%F_Counts%OutOfWellIntervalCounts+1),data%State%F_Counts%IntervalsTotalCounts do kk = jj,1,-1 if ( data%State%F_Interval(ii)%StartDepth==data%State%TDGeo%MD(kk) ) then data%State%F_Interval(ii)%StartTVD = data%State%TDGeo%TVD(kk) ![ft] data%State%F_Interval(ii)%StartAngle = data%State%TDGeo%Angle(kk) ![rad] end if if ( data%State%F_Interval(ii)%EndDepth==data%State%TDGeo%MD(kk) ) then data%State%F_Interval(ii)%EndTVD = data%State%TDGeo%TVD(kk) ![ft] data%State%F_Interval(ii)%EndAngle = data%State%TDGeo%Angle(kk) ![rad] end if end do End Do !Do ii=1,(data%State%F_Counts%IntervalsTotalCounts) ! print*, 'data%State%F_Interval(ii)%StartTVD=' , ii , data%State%F_Interval(ii)%StartTVD ! print*, 'data%State%F_Interval(ii)%EndTVD=' , ii , data%State%F_Interval(ii)%EndTVD ! print*, 'data%State%F_Interval(ii)%StartAngle=' , ii , data%State%F_Interval(ii)%StartAngle ! print*, 'data%State%F_Interval(ii)%EndAngle=' , ii , data%State%F_Interval(ii)%EndAngle !end do ! ! !Do ii=1,data%State%TD_WellGeneral%WellIntervalsCount ! print*, 'data%State%TD_WellGeo(kk)%TopDepth=' , ii , data%State%TD_WellGeo(ii)%TopDepth ! print*, 'data%State%TD_WellGeo(kk)%DownDepth=' , ii , data%State%TD_WellGeo(ii)%DownDepth ! print*, 'data%State%TD_WellGeo(kk)%HoleType=' , ii , data%State%TD_WellGeo(ii)%HoleType ! print*, 'data%State%TD_WellGeo(kk)%RCurvature=' , ii , data%State%TD_WellGeo(ii)%RCurvature ! print*, 'data%State%TD_WellGeo(kk)%EndAngle=' , ii , data%State%TD_WellGeo(ii)%EndAngle ! print*, 'data%State%TD_WellGeo(kk)%StartAngle=' , ii , data%State%TD_WellGeo(ii)%StartAngle !end do end subroutine