@@ -466,7 +466,7 @@ SUBROUTINE ADI_C_Init( ADinputFilePassed, ADinputFileString_C, ADinputFileString
466466 character (ErrMsgLen) :: ErrMsg ! < aggregated error message
467467 integer (IntKi) :: ErrStat2 ! < temporary error status from a call
468468 character (ErrMsgLen) :: ErrMsg2 ! < temporary error message from a call
469- character (IntfStrLen) :: OutVTKdir ! < Output directory for files (relative to current location)
469+ character (IntfStrLen) :: OutVTKDir ! < Output directory for files (relative to current location)
470470 integer (IntKi) :: i,j,k ! < generic index variables
471471 integer (IntKi) :: iWT ! < current turbine number (iterate through during setup for ADI_Init call)
472472 integer (IntKi) :: AeroProjMod ! < for checking that all turbines use the same AeroProjMod
@@ -517,10 +517,10 @@ SUBROUTINE ADI_C_Init( ADinputFilePassed, ADinputFileString_C, ADinputFileString
517517 i = INDEX (OutRootName,C_NULL_CHAR) - 1 ! if this has a c null character at the end...
518518 if ( i > 0 ) OutRootName = OutRootName(1 :I) ! remove it
519519
520- ! OutVTKdir -- output directory
521- OutVTKdir = TRANSFER ( OutVTKdir_C, OutVTKdir )
522- i = INDEX (OutVTKdir ,C_NULL_CHAR) - 1 ! if this has a c null character at the end...
523- if ( i > 0 ) OutVTKdir = OutVTKdir (1 :I) ! remove it
520+ ! OutVTKDir -- output directory
521+ OutVTKDir = TRANSFER ( OutVTKDir_C, OutVTKDir )
522+ i = INDEX (OutVTKDir ,C_NULL_CHAR) - 1 ! if this has a c null character at the end...
523+ if ( i > 0 ) OutVTKDir = OutVTKDir (1 :I) ! remove it
524524
525525 ! For debugging the interface:
526526 if (DebugLevel > 0 ) then
@@ -669,10 +669,10 @@ SUBROUTINE ADI_C_Init( ADinputFilePassed, ADinputFileString_C, ADinputFileString
669669 call SetupMotionLoadsInterfaceMeshes(); if (Failed()) return
670670 ! setup meshes
671671 if (WrOutputsData% WrVTK > 0_IntKi ) then
672- if (len_trim (OutVTKdir ) <= 0 ) then
673- OutVTKdir = ' vtk-ADI'
672+ if (len_trim (OutVTKDir ) <= 0 ) then
673+ OutVTKDir = ' vtk-ADI'
674674 endif
675- call setVTKParameters(WrOutputsData, Sim, ADI, ErrStat2, ErrMsg2, OutVTKdir )
675+ call setVTKParameters(WrOutputsData, Sim, ADI, ErrStat2, ErrMsg2, OutVTKDir )
676676 if (Failed()) return
677677 endif
678678 ! write meshes for this rotor
@@ -682,6 +682,8 @@ SUBROUTINE ADI_C_Init( ADinputFilePassed, ADinputFileString_C, ADinputFileString
682682 enddo
683683 if (Failed()) return
684684 endif
685+ ! Map the meshes (doing this after writing so we can check if it fails)
686+ call MapLoadsInterfaceMeshes(); if (Failed()) return
685687
686688 ! Setup points for calculating disk average velocity
687689 do iWT= 1 ,Sim% NumTurbines
@@ -771,10 +773,12 @@ SUBROUTINE ADI_C_Init( ADinputFilePassed, ADinputFileString_C, ADinputFileString
771773
772774
773775CONTAINS
774- logical function Failed ()
776+ logical function Failed (Msg )
777+ character (* ), optional :: Msg
775778 CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
776779 Failed = ErrStat >= AbortErrLev
777780 if (Failed) then
781+ if (present (Msg)) ErrMsg = trim (ErrMsg)// ' (' // trim (Msg)// ' )'
778782 call ClearTmpStorage()
779783 call SetErr(ErrStat,ErrMsg,ErrStat_C,ErrMsg_C)
780784 endif
@@ -959,8 +963,8 @@ subroutine SetupMotionLoadsInterfaceMeshes()
959963 do iBlade= 1 ,Sim% WT(iWT)% NumBlades
960964 !- ------------------------------------------------------------
961965 ! Load mesh for blades
962- CALL MeshCopy( SrcMesh = BldStrMotionMesh(iWT)% Mesh(iBlade) ,&
963- DestMesh = BldStrLoadMesh(iWT)% Mesh(iBlade) ,&
966+ CALL MeshCopy( SrcMesh = BldStrMotionMesh(iWT)% Mesh(iBlade) ,&
967+ DestMesh = BldStrLoadMesh(iWT)% Mesh(iBlade) ,&
964968 CtrlCode = MESH_SIBLING ,&
965969 IOS = COMPONENT_OUTPUT ,&
966970 ErrStat = ErrStat2 ,&
@@ -971,8 +975,8 @@ subroutine SetupMotionLoadsInterfaceMeshes()
971975 BldStrMotionMesh(iWT)% Mesh(iBlade)% RemapFlag = .FALSE.
972976
973977 ! Temp mesh for load transfer
974- CALL MeshCopy( SrcMesh = BldStrLoadMesh(iWT)% Mesh(iBlade) ,&
975- DestMesh = BldStrLoadMesh_tmp(iWT)% Mesh(iBlade) ,&
978+ CALL MeshCopy( SrcMesh = BldStrLoadMesh(iWT)% Mesh(iBlade) ,&
979+ DestMesh = BldStrLoadMesh_tmp(iWT)% Mesh(iBlade) ,&
976980 CtrlCode = MESH_COUSIN ,&
977981 IOS = COMPONENT_OUTPUT ,&
978982 ErrStat = ErrStat2 ,&
@@ -985,16 +989,30 @@ subroutine SetupMotionLoadsInterfaceMeshes()
985989 ! For checking the mesh
986990 ! Note: CU is is output unit (platform dependent).
987991 if (DebugLevel >= 4 ) call MeshPrintInfo( CU, BldStrLoadMesh(iWT)% Mesh(iBlade), MeshName= ' BldStrLoadMesh' // trim (Num2LStr(iWT))// ' _' // trim (Num2LStr(iBlade)) )
992+ enddo ! iBlade
993+ enddo ! iWT
994+ end subroutine SetupMotionLoadsInterfaceMeshes
988995
996+ ! > This subroutine sets the interface meshes to map to the input motions to the AD
997+ ! ! meshes
998+ subroutine MapLoadsInterfaceMeshes ()
999+ integer (IntKi) :: iWT ! < current rotor/turbine
1000+ integer (IntKi) :: iBlade ! < current blade
1001+
1002+ ! Step through all turbine rotors
1003+ do iWT= 1 ,Sim% NumTurbines
1004+ !- ------------------------------------------------------------
1005+ ! Load mesh for blades
1006+ ! Step through all blades on this rotor
1007+ do iBlade= 1 ,Sim% WT(iWT)% NumBlades
9891008 !- ------------------------------------------------------------
9901009 ! Set the mapping meshes
9911010 ! blades
992- call MeshMapCreate( BldStrMotionMesh(iWT)% Mesh(iBlade), ADI% u(1 )% AD% rotors(iWT)% BladeMotion(iBlade), Map_BldStrMotion_2_AD_Blade(iBlade, iWT), ErrStat2, ErrMsg2 ); if (Failed()) return
993- call MeshMapCreate( ADI% y% AD% rotors(iWT)% BladeLoad(iBlade), BldStrLoadMesh(iWT)% Mesh(iBlade), Map_AD_BldLoad_P_2_BldStrLoad(iBlade, iWT), ErrStat2, ErrMsg2 ); if (Failed()) return
1011+ call MeshMapCreate( BldStrMotionMesh(iWT)% Mesh(iBlade), ADI% u(1 )% AD% rotors(iWT)% BladeMotion(iBlade), Map_BldStrMotion_2_AD_Blade(iBlade, iWT), ErrStat2, ErrMsg2 ); if (Failed(' Struct to blade ' // trim (Num2LStr(iBlade)) )) return
1012+ call MeshMapCreate( ADI% y% AD% rotors(iWT)% BladeLoad(iBlade), BldStrLoadMesh(iWT)% Mesh(iBlade), Map_AD_BldLoad_P_2_BldStrLoad(iBlade, iWT), ErrStat2, ErrMsg2 ); if (Failed(' Blade ' // trim (Num2LStr(iBlade)) // ' to struct ' )) return
9941013 enddo ! iBlade
9951014 enddo ! iWT
996-
997- end subroutine SetupMotionLoadsInterfaceMeshes
1015+ end subroutine MapLoadsInterfaceMeshes
9981016
9991017
10001018 !- ------------------------------------------------------------
@@ -1424,7 +1442,7 @@ subroutine ADI_C_SetupRotor(iWT_c, TurbineIsHAWT_c, TurbOrigin_C, &
14241442 integer (IntKi) :: ErrStat2 ! < temporary error status from a call
14251443 character (ErrMsgLen) :: ErrMsg2 ! < temporary error message from a call
14261444 integer (IntKi) :: i,j,k ! < generic index variables
1427- character (* ), parameter :: RoutineName = ' ADI_C_Init ' ! < for error handling
1445+ character (* ), parameter :: RoutineName = ' ADI_C_SetupRotor ' ! < for error handling
14281446
14291447 ! Initialize error handling
14301448 ErrStat = ErrID_None
@@ -1493,6 +1511,9 @@ subroutine ADI_C_SetupRotor(iWT_c, TurbineIsHAWT_c, TurbOrigin_C, &
14931511 if (Failed()) return
14941512 endif
14951513
1514+ ! check Mesh points for blade specification
1515+ call CheckMeshPts(iWT); if (Failed()) return
1516+
14961517 call SetupMotionMesh()
14971518
14981519 ! Set error status
@@ -1523,8 +1544,9 @@ end function Failed0
15231544 ! > This subroutine prints out all the variables that are passed in. Use this only
15241545 ! ! for debugging the interface on the Fortran side.
15251546 subroutine ShowPassedData ()
1526- character (1 ) :: TmpFlag
1527- integer :: i,j
1547+ character (1 ) :: TmpFlag
1548+ integer :: i,j
1549+ character (35 ) :: TmpStr
15281550 call WrSCr(" " )
15291551 call WrScr(" -----------------------------------------------------------" )
15301552 call WrScr(" Interface debugging: Variables passed in through interface" )
@@ -1566,10 +1588,28 @@ subroutine ShowPassedData()
15661588 j= 9 * (i-1 )
15671589 call WrMatrix(InitMeshOri_C(j+1 :j+9 ),CU,' (9(ES23.15e2))' )
15681590 enddo
1591+ call WrScr(" Node mapping" )
1592+ call WrScr(" MeshPt Blade" )
1593+ do i= 1 ,int (NumMeshPts_C,IntKi)
1594+ write (TmpStr,' (15X,I5,10X,I5)' ) i,int (MeshPtToBladeNum_C(i),IntKi)
1595+ call WrScr(TmpStr)
1596+ enddo
15691597 endif
15701598 call WrScr(" -----------------------------------------------------------" )
15711599 end subroutine ShowPassedData
15721600
1601+ ! > very basic checks on mesh points
1602+ subroutine CheckMeshPts (iWT )
1603+ integer (IntKi), intent (in ) :: iWT
1604+ do i= 1 ,size (MeshPtToBladeNum_C)
1605+ if ((MeshPtToBladeNum_C(i) < 1_c_int ) .or. (MeshPtToBladeNum_C(i) > int (Sim% WT(iWT)% NumBlades))) then
1606+ ErrStat2= ErrID_Fatal
1607+ ErrMsg2 = ' Mesh Point ' // trim (Num2LStr(i))// ' assigned to invalid blade ' // trim (Num2LStr(MeshPtToBladeNum_C(i)))// ' on rotor ' // trim (Num2LStr(iWT))
1608+ if (Failed()) return
1609+ endif
1610+ enddo
1611+ end subroutine CheckMeshPts
1612+
15731613 subroutine SetupMotionMesh ()
15741614 real (ReKi) :: InitPos(3 )
15751615 real (R8 Ki) :: Orient(3 ,3 )
@@ -2302,7 +2342,7 @@ subroutine WrVTK_PointsRef(ErrStat3,ErrMsg3)
23022342
23032343 ! Blade point motion (structural mesh from driver)
23042344 do iBlade= 1 ,Sim% WT(iWT)% NumBlades
2305- call MeshWrVTKreference(RefPoint, BldStrMotionMesh(iWT)% Mesh(iBlade), trim (WrOutputsData% VTK_OutFileRoot)// trim (sWT)// ' .BldStrMotionMesh' , ErrStat3, ErrMsg3)
2345+ call MeshWrVTKreference(RefPoint, BldStrMotionMesh(iWT)% Mesh(iBlade), trim (WrOutputsData% VTK_OutFileRoot)// trim (sWT)// ' .BldStrMotionMesh' // trim (Num2LStr(iBlade)) , ErrStat3, ErrMsg3)
23062346 if (ErrStat3 >= AbortErrLev) return
23072347 enddo
23082348
@@ -2409,7 +2449,7 @@ subroutine WrVTK_Points(ErrStat3,ErrMsg3)
24092449
24102450 ! Blade point motion (structural mesh from driver)
24112451 do iBlade= 1 ,Sim% WT(iWT)% NumBlades
2412- call MeshWrVTK(RefPoint, BldStrMotionMesh(iWT)% Mesh(iBlade), trim (WrOutputsData% VTK_OutFileRoot)// trim (sWT)// ' .BldStrMotionMesh' // trim (num2lstr (iBlade)), n_VTK, .true. , ErrStat3, ErrMsg3, WrOutputsData% VTK_tWidth)
2452+ call MeshWrVTK(RefPoint, BldStrMotionMesh(iWT)% Mesh(iBlade), trim (WrOutputsData% VTK_OutFileRoot)// trim (sWT)// ' .BldStrMotionMesh' // trim (Num2LStr (iBlade)), n_VTK, .true. , ErrStat3, ErrMsg3, WrOutputsData% VTK_tWidth)
24132453 if (ErrStat3 >= AbortErrLev) return
24142454 enddo
24152455
0 commit comments