diff --git a/.gitignore b/.gitignore index 5a438dc04..8c3981be2 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,12 @@ src/build/libadflow-f2pywrappers.f src/build/libadflowmodule.c src/build/importTest.py +# unused fast_b routines generated by Tapenade +src/adjoint/outputReverseFast/adjointextra_fast_b.f90 +src/adjoint/outputReverseFast/bcdata_fast_b.f90 +src/adjoint/outputReverseFast/oversetutilities_fast_b.f90 +src/adjoint/outputReverseFast/zipperintegrations_fast_b.f90 + # Regression test auxiliary files: input_files.tar.gz adflow_input_files.tar.gz diff --git a/adflow/pyADflow.py b/adflow/pyADflow.py index 3c7a6a284..5a2f805a2 100644 --- a/adflow/pyADflow.py +++ b/adflow/pyADflow.py @@ -141,6 +141,9 @@ def __init__(self, comm=None, options=None, debug=False, dtype="d"): # Set all internal adflow default options before we set anything from python self.adflow.inputparamroutines.setdefaultvalues() + # surface-roughness overwrite-dict + self.surfaceRoughness = dict() + defSetupTime = time.time() # Initialize the inherited AeroSolver @@ -1162,6 +1165,50 @@ def setRotationRate(self, rotCenter, rotRate, cgnsBlocks=None): self.adflow.preprocessingapi.updaterotationrate(rotCenter, rotations, cgnsBlocks) self._updateVelInfo = True + def setSurfaceRoughness(self, ks, groupName=None): + """ + Sets the equivalent sandgrain roughness on the specified surface family. + It may only be used when the rough SA-variant (useRoughSA = True) is + active. + + This function takes precendence over all boundary conditions set in the + mesh. + + Parameters: + ---------- + ks : float + Equivalent sandgrain roughness + groupName : str + Family group to use. Default to all walls if not given (None) + """ + + if not self.options["useroughsa"]: + raise Error( + "It is not possible to set a surface roughness value without " + "using the rough SA-variant (useRoughSA = False)" + ) + + if groupName is None: + groupName = self.allWallsGroup + + if groupName in self.surfaceRoughness: + raise Error( + f"The roughness value for surface group '{groupName}' has " + f"allready been set to {self.surfaceRoughness[groupName]}" + ) + + self.surfaceRoughness[groupName] = ks + + def _setSurfaceRoughness(self): + """ + Set the actual roughness values. It must be postponed for as long as + possible. Otherwise it might get overwritten. + """ + + for groupName, ks in self.surfaceRoughness.items(): + famList = self._getFamilyList(groupName) + self.adflow.preprocessingapi.updatesurfaceroughness(ks, famList) + def checkPartitioning(self, nprocs): """This function determines the potential load balancing for nprocs. The intent is this function can be run in serial @@ -3706,6 +3753,13 @@ def _setAeroProblemData(self, aeroProblem, firstCall=False): self.adflow.preprocessingapi.updatemetricsalllevels() self.adflow.preprocessingapi.updategridvelocitiesalllevels() + # overwrite BC surface roughness + if len(self.surfaceRoughness) > 0: + self._setSurfaceRoughness() + + # Propagate roughness values through volume + self.adflow.walldistance.updatewallroughness() + def _getBCDataFromAeroProblem(self, AP): variables = [] dataArray = [] @@ -5675,6 +5729,7 @@ def _getDefaultOptions(): "useQCR": [bool, False], "useRotationSA": [bool, False], "useft2SA": [bool, True], + "useRoughSA": [bool, False], "eddyVisInfRatio": [float, 0.009], "useWallFunctions": [bool, False], "useApproxWallDistance": [bool, True], @@ -6070,6 +6125,7 @@ def _getOptionMap(self): "useqcr": ["physics", "useqcr"], "userotationsa": ["physics", "userotationsa"], "useft2sa": ["physics", "useft2sa"], + "useroughsa": ["physics", "useroughsa"], "eddyvisinfratio": ["physics", "eddyvisinfratio"], "usewallfunctions": ["physics", "wallfunctions"], "walldistcutoff": ["physics", "walldistcutoff"], diff --git a/doc/options.yaml b/doc/options.yaml index f37f0f5da..826e31c7b 100644 --- a/doc/options.yaml +++ b/doc/options.yaml @@ -237,6 +237,15 @@ useft2SA: desc: > Include the ft2 term in the Spalart-Allmaras turbulence model. +useRoughSA: + desc: > + Activates the rough SA variant described `here + `__. To use it, + blockettes must be disabled ``useBlockettes: False``. The roughness value on + the boundary may be prescribed like a regular boundary value using the name + ``SandGrainRoughness``. Additionally, the ADflow method ``setSurfaceRoughness`` + may be used. + eddyVisInfRatio: desc: > Free stream value of eddy viscosity. @@ -1613,4 +1622,3 @@ meshMaxSkewness: useSkewnessCheck: desc: > When set to true, ADflow computes the `skewness` of each cell and throws an error if it is above ``meshMaxSkewness``. See also ``printBadlySkewedCells``. - diff --git a/src/NKSolver/blockette.F90 b/src/NKSolver/blockette.F90 index 6ce106c2e..3f34686f0 100644 --- a/src/NKSolver/blockette.F90 +++ b/src/NKSolver/blockette.F90 @@ -86,7 +86,7 @@ subroutine blocketteRes(useDissApprox, useViscApprox, useUpdateIntermed, useFlow use initializeFlow, only: referenceState use section, only: sections, nSections use iteration, only: rFil, currentLevel - use haloExchange, only: exchangeCoor, whalo2 + use haloExchange, only: exchangeCoor, whalo2, exchanged2Wall use wallDistance, only: updateWallDistancesQuickly use utils, only: setPointers, EChk use turbUtils, only: computeEddyViscosity @@ -181,12 +181,20 @@ subroutine blocketteRes(useDissApprox, useViscApprox, useUpdateIntermed, useFlow do nn = 1, nDom call setPointers(nn, currentLevel, sps) call xhalo_block() + + if (equations == RANSEquations .and. useApproxWallDistance) then + call updateWallDistancesQuickly(nn, 1, sps) + end if end do end do ! Now exchange the coordinates (fine level only) call exchangecoor(1) + if (equations == RANSEquations .and. useApproxWallDistance) then + call exchanged2Wall(1) + end if + do sps = 1, nTimeIntervalsSpectral ! Update overset connectivity if necessary if (oversetPresent .and. oversetUpdateMode == updateFast) then diff --git a/src/adjoint/Makefile_tapenade b/src/adjoint/Makefile_tapenade index d0077a2ea..fc2686635 100644 --- a/src/adjoint/Makefile_tapenade +++ b/src/adjoint/Makefile_tapenade @@ -132,17 +132,17 @@ flowUtils%computeEtotBlock(w, p) > \ \ turbUtils%computeEddyViscosity(w,rlv)>(w,rlv,rev) \ \ -BCRoutines%bcSymm1stHalo(ww1, ww2, pp1, pp2, rlv1, rlv2, rev1, rev2, bcData%norm) > \ - (ww1, ww2, pp1, pp2, rlv1, rlv2, rev1, rev2, bcData%norm) \ +BCRoutines%bcSymm1stHalo(ww1, ww2, pp1, pp2, rlv1, rlv2, rev1, rev2, d2wall1, d2wall2, bcData%norm) > \ + (ww1, ww2, pp1, pp2, rlv1, rlv2, rev1, rev2, d2wall1, d2wall2, bcData%norm) \ \ -BCRoutines%bcSymm2ndHalo(ww0, ww3, pp0, pp3, rlv0, rlv3, rev0, rev3, bcData%norm) > \ - (ww0, ww3, pp0, pp3, rlv0, rlv3, rev0, rev3, bcData%norm) \ +BCRoutines%bcSymm2ndHalo(ww0, ww3, pp0, pp3, rlv0, rlv3, rev0, rev3, bd2wall0, d2wall3, cData%norm) > \ + (ww0, ww3, pp0, pp3, rlv0, rlv3, rev0, rev3, bd2wall0, d2wall3, bcData%norm) \ \ -BCRoutines%bcSymmPolar1stHalo(xx, ww1, ww2, pp1, pp2, rlv1, rlv2, rev1, rev2) > \ - (xx, ww1, ww2, pp1, pp2, rlv1, rlv2, rev1, rev2) \ +BCRoutines%bcSymmPolar1stHalo(xx, ww1, ww2, pp1, pp2, rlv1, rlv2, rev1, rev2, d2wall1, d2wall2) > \ + (xx, ww1, ww2, pp1, pp2, rlv1, rlv2, rev1, rev2, d2wall1, d2wall2) \ \ -BCRoutines%bcSymmPolar2ndHalo(xx, ww0, ww3, pp0, pp3, rlv0, rlv3, rev0, rev3) > \ - (xx, ww0, ww3, pp0, pp3, rlv0, rlv3, rev0, rev3) \ +BCRoutines%bcSymmPolar2ndHalo(xx, ww0, ww3, pp0, pp3, rlv0, rlv3, rev0, rev3, d2wall0, d2wall3) > \ + (xx, ww0, ww3, pp0, pp3, rlv0, rlv3, rev0, rev3, d2wall0, d2wall3) \ \ BCRoutines%bcNSWallAdiabatic(ww0, ww1, ww2, pp0, pp1, pp2, pp3, rlv0, rlv1, rlv2, rev0, rev1, rev2, bcData%uSlip) > \ (ww0, ww1, ww2, pp0, pp1, pp2, pp3, rlv0, rlv1, rlv2, rev0, rev1, rev2, bcData%uSlip) \ @@ -162,11 +162,11 @@ BCRoutines%bcSubsonicInflow(ww0, ww1, ww2, pp0, pp1, pp2, rlv0, rlv1, rlv2, rev0 BCRoutines%bcSubsonicOutflow(ww0, ww1, ww2, pp0, pp1, pp2, rlv0, rlv1, rlv2, rev0, rev1, rev2, bcData%norm, bcData%Ps) > \ (ww0, ww1, ww2, pp0, pp1, pp2, rlv0, rlv1, rlv2, rev0, rev1, rev2, bcData%norm, bcData%Ps) \ \ -turbBCRoutines%applyAllTurbBCThisBlock(rev, w, bvtj1, bvtj2, bvtk1, bvtk2, bvti1, bvti2) > \ - (rev, w) \ +turbBCRoutines%applyAllTurbBCThisBlock(rev, w, bvtj1, bvtj2, bvtk1, bvtk2, bvti1, bvti2, bmti1, bmti2, bmtj1, bmtj2, bmtk1, bmtk2, d2wall) > \ + (rev, w, bvtj1, bvtj2, bvtk1, bvtk2, bvti1, bvti2, bmti1, bmti2, bmtj1, bmtj2, bmtk1, bmtk2, d2wall) \ \ -turbBCRoutines%bcTurbTreatment(w, rlv, d2wall, winf) > \ - (w, rlv, d2wall, winf, bvtj1, bvtj2, bvtk1, bvtk2, bvti1, bvti2) \ +turbBCRoutines%bcTurbTreatment(w, rlv, d2wall, winf, bvtj1, bvtj2, bvtk1, bvtk2, bvti1, bvti2, bmti1, bmti2, bmtj1, bmtj2, bmtk1, bmtk2) > \ + (w, rlv, d2wall, winf, bvtj1, bvtj2, bvtk1, bvtk2, bvti1, bvti2, bmti1, bmti2, bmtj1, bmtj2, bmtk1, bmtk2) \ \ solverUtils%timeStep_block(w, pInfCorr, rhoInf, si, sj, sk, sFaceI, sFaceJ, sFaceK, p, radi, radj, radk, dtl, rlv, rev, vol) > \ (w, pInfCorr, rhoInf, si, sj, sk, sFaceI, sFaceJ, sFaceK, p, radi, radj, radk, dtl, rlv, rev, vol) \ diff --git a/src/adjoint/adjointUtils.F90 b/src/adjoint/adjointUtils.F90 index 14641f51f..b2a5a85a2 100644 --- a/src/adjoint/adjointUtils.F90 +++ b/src/adjoint/adjointUtils.F90 @@ -772,8 +772,10 @@ subroutine allocDerivativeValues(level) ! Allocate d2wall if not already done so if (.not. associated(flowDoms(nn, 1, sps)%d2wall)) then - allocate (flowDoms(nn, 1, sps)%d2wall(2:il, 2:jl, 2:kl)) + allocate (flowDoms(nn, 1, sps)%d2wall(0:ib, 0:jb, 0:kb)) call EChk(ierr, __FILE__, __LINE__) + + flowDoms(nn, level, sps)%d2Wall = 0.01 end if ! Now allocate all valus that have a differentiable @@ -829,7 +831,7 @@ subroutine allocDerivativeValues(level) flowDomsd(nn, level, sps)%bvtj2(ie, ke, nt1:nt2), & flowDomsd(nn, level, sps)%bvtk1(ie, je, nt1:nt2), & flowDomsd(nn, level, sps)%bvtk2(ie, je, nt1:nt2), & - flowDomsd(nn, level, sps)%d2Wall(2:il, 2:jl, 2:kl), & + flowDomsd(nn, level, sps)%d2Wall(0:ib, 0:jb, 0:kb), & stat=ierr) call EChk(ierr, __FILE__, __LINE__) diff --git a/src/adjoint/outputForward/BCData_d.f90 b/src/adjoint/outputForward/BCData_d.f90 index 5f28fb4df..9593cac1f 100644 --- a/src/adjoint/outputForward/BCData_d.f90 +++ b/src/adjoint/outputForward/BCData_d.f90 @@ -13,11 +13,28 @@ module bcdata_d subroutine setbcvarnamesisothermalwall() use cgnsnames use constants + use inputphysics, only : useroughsa implicit none nbcvar = nbcvarisothermalwall bcvarnames(1) = cgnstemp + if (useroughsa) then + nbcvar = nbcvar + 1 + bcvarnames(2) = cgnssandgrainroughness + end if end subroutine setbcvarnamesisothermalwall + subroutine setbcvarnamesadiabaticwall() + use cgnsnames + use constants + use inputphysics, only : useroughsa + implicit none + nbcvar = nbcvaradiabaticwall + if (useroughsa) then + nbcvar = nbcvar + 1 + bcvarnames(1) = cgnssandgrainroughness + end if + end subroutine setbcvarnamesadiabaticwall + subroutine setbcvarnamessubsonicinflow() use constants use cgnsnames @@ -329,10 +346,10 @@ subroutine unitvectorscylsystem(boco) end subroutine unitvectorscylsystem ! differentiation of bcdataisothermalwall in forward (tangent) mode (with options i4 dr8 r8): -! variations of useful results: *(*bcdata.tns_wall) +! variations of useful results: *(*bcdata.tns_wall) bcvararray ! with respect to varying inputs: tref bcvararray ! rw status of diff variables: tref:in *(*bcdata.tns_wall):out -! bcvararray:in +! bcvararray:in-out ! plus diff mem management of: bcdata:in *bcdata.tns_wall:in ! --------------------------------------------------------------- ! routines that set the actual bcdata values from the cgns data set @@ -350,6 +367,7 @@ subroutine bcdataisothermalwall_d(boco, bcvararray, bcvararrayd, ibeg& use blockpointers, only : bcfaceid, bcdata, bcdatad, nbkglobal use utils_d, only : terminate, sitemperature use flowvarrefstate, only : tref, trefd + use inputphysics, only : useroughsa use diffsizes ! hint: isize1ofdrfbcdata should be the size of dimension 1 of array *bcdata implicit none @@ -388,6 +406,21 @@ subroutine bcdataisothermalwall_d(boco, bcvararray, bcvararrayd, ibeg& bcdata(boco)%tns_wall(i, j) = temp0 end do end do +! set a value of 0 if it was not possible to determine the +! sand grain roughness + if (useroughsa) then +! set a value of 0 if it was not possible to determine the +! sand grain roughness + if (.not.bcvarpresent(1)) then + bcvararrayd(:, :, 2) = 0.0_8 + bcvararray(:, :, 2) = zero + end if + do j=jbeg,jend + do i=ibeg,iend + bcdata(boco)%ksns_wall(i, j) = bcvararray(i, j, 2) + end do + end do + end if end subroutine bcdataisothermalwall_d ! --------------------------------------------------------------- @@ -406,6 +439,7 @@ subroutine bcdataisothermalwall(boco, bcvararray, ibeg, iend, jbeg, & use blockpointers, only : bcfaceid, bcdata, nbkglobal use utils_d, only : terminate, sitemperature use flowvarrefstate, only : tref + use inputphysics, only : useroughsa implicit none ! ! subroutine arguments. @@ -431,8 +465,54 @@ subroutine bcdataisothermalwall(boco, bcvararray, ibeg, iend, jbeg, & & tref end do end do +! set a value of 0 if it was not possible to determine the +! sand grain roughness + if (useroughsa) then +! set a value of 0 if it was not possible to determine the +! sand grain roughness + if (.not.bcvarpresent(1)) bcvararray(:, :, 2) = zero + do j=jbeg,jend + do i=ibeg,iend + bcdata(boco)%ksns_wall(i, j) = bcvararray(i, j, 2) + end do + end do + end if end subroutine bcdataisothermalwall + subroutine bcdataadiabaticwall(boco, bcvararray, ibeg, iend, jbeg, & +& jend) +! +! tries to extract the equivalent sand grain roughness. it sets +! a default value of 0.0 +! + use constants + use cgnsnames + use inputphysics, only : useroughsa + use blockpointers, only : bcfaceid, bcdata, nbkglobal + implicit none +! +! subroutine arguments. +! + integer(kind=inttype) :: boco + integer(kind=inttype) :: ibeg, iend, jbeg, jend + real(kind=realtype), dimension(ibeg:iend, jbeg:jend, nbcvarmax) :: & +& bcvararray +! +! local variables. +! + integer(kind=inttype) :: i, j + if (useroughsa) then +! set a value of 0 if it was not possible to determine the +! sand grain roughness + if (.not.bcvarpresent(1)) bcvararray(:, :, 1) = zero + do j=jbeg,jend + do i=ibeg,iend + bcdata(boco)%ksns_wall(i, j) = bcvararray(i, j, 1) + end do + end do + end if + end subroutine bcdataadiabaticwall + ! differentiation of bcdatasubsonicinflow in forward (tangent) mode (with options i4 dr8 r8): ! variations of useful results: *(*bcdata.ptinlet) *(*bcdata.ttinlet) ! *(*bcdata.htinlet) *(*bcdata.turbinlet) diff --git a/src/adjoint/outputForward/BCRoutines_d.f90 b/src/adjoint/outputForward/BCRoutines_d.f90 index 3d28d0bbf..16967bf6e 100644 --- a/src/adjoint/outputForward/BCRoutines_d.f90 +++ b/src/adjoint/outputForward/BCRoutines_d.f90 @@ -156,14 +156,15 @@ subroutine applyallbc_block(secondhalo) end subroutine applyallbc_block ! differentiation of bcsymm1sthalo in forward (tangent) mode (with options i4 dr8 r8): -! variations of useful results: *rev1 *pp1 *rlv1 *ww1 -! with respect to varying inputs: *rev1 *rev2 *pp1 *pp2 *rlv1 -! *rlv2 *ww1 *ww2 *(*bcdata.norm) -! rw status of diff variables: *rev1:in-out *rev2:in *pp1:in-out -! *pp2:in *rlv1:in-out *rlv2:in *ww1:in-out *ww2:in -! *(*bcdata.norm):in -! plus diff mem management of: rev1:in rev2:in pp1:in pp2:in -! rlv1:in rlv2:in ww1:in ww2:in bcdata:in *bcdata.norm:in +! variations of useful results: *rev1 *d2wall1 *pp1 *rlv1 *ww1 +! with respect to varying inputs: *rev1 *rev2 *d2wall1 *d2wall2 +! *pp1 *pp2 *rlv1 *rlv2 *ww1 *ww2 *(*bcdata.norm) +! rw status of diff variables: *rev1:in-out *rev2:in *d2wall1:in-out +! *d2wall2:in *pp1:in-out *pp2:in *rlv1:in-out *rlv2:in +! *ww1:in-out *ww2:in *(*bcdata.norm):in +! plus diff mem management of: rev1:in rev2:in d2wall1:in d2wall2:in +! pp1:in pp2:in rlv1:in rlv2:in ww1:in ww2:in bcdata:in +! *bcdata.norm:in ! =================================================================== ! actual implementation of each of the boundary condition routines ! =================================================================== @@ -179,9 +180,11 @@ subroutine bcsymm1sthalo_d(nn) use constants use blockpointers, only : bcdata, bcdatad use flowvarrefstate, only : viscous, eddymodel + use inputphysics, only : useroughsa use bcpointers_d, only : gamma1, gamma2, ww1, ww1d, ww2, ww2d, pp1, & & pp1d, pp2, pp2d, rlv1, rlv1d, rlv2, rlv2d, istart, jstart, isize, & -& jsize, rev1, rev1d, rev2, rev2d +& jsize, rev1, rev1d, rev2, rev2d, d2wall1, d2wall1d, d2wall2, & +& d2wall2d, ks1, ks2 implicit none ! subroutine arguments. integer(kind=inttype), intent(in) :: nn @@ -232,6 +235,9 @@ subroutine bcsymm1sthalo_d(nn) gamma1(i, j) = gamma2(i, j) pp1d(i, j) = pp2d(i, j) pp1(i, j) = pp2(i, j) + d2wall1d(i, j) = d2wall2d(i, j) + d2wall1(i, j) = d2wall2(i, j) + if (useroughsa) ks1(i, j) = ks2(i, j) if (viscous) then rlv1d(i, j) = rlv2d(i, j) rlv1(i, j) = rlv2(i, j) @@ -258,8 +264,10 @@ subroutine bcsymm1sthalo(nn) use constants use blockpointers, only : bcdata use flowvarrefstate, only : viscous, eddymodel + use inputphysics, only : useroughsa use bcpointers_d, only : gamma1, gamma2, ww1, ww2, pp1, pp2, rlv1, & -& rlv2, istart, jstart, isize, jsize, rev1, rev2 +& rlv2, istart, jstart, isize, jsize, rev1, rev2, d2wall1, d2wall2, & +& ks1, ks2 implicit none ! subroutine arguments. integer(kind=inttype), intent(in) :: nn @@ -289,6 +297,8 @@ subroutine bcsymm1sthalo(nn) ! laminar and eddy viscosity in the halo. gamma1(i, j) = gamma2(i, j) pp1(i, j) = pp2(i, j) + d2wall1(i, j) = d2wall2(i, j) + if (useroughsa) ks1(i, j) = ks2(i, j) if (viscous) rlv1(i, j) = rlv2(i, j) if (eddymodel) rev1(i, j) = rev2(i, j) end do @@ -297,12 +307,11 @@ end subroutine bcsymm1sthalo ! differentiation of bcsymm2ndhalo in forward (tangent) mode (with options i4 dr8 r8): ! variations of useful results: *rev0 *pp0 *rlv0 *ww0 ! with respect to varying inputs: *rev0 *rev3 *pp0 *pp3 *rlv0 -! *rlv3 *ww0 *ww3 *(*bcdata.norm) +! *rlv3 *ww0 *ww3 ! rw status of diff variables: *rev0:in-out *rev3:in *pp0:in-out ! *pp3:in *rlv0:in-out *rlv3:in *ww0:in-out *ww3:in -! *(*bcdata.norm):in ! plus diff mem management of: rev0:in rev3:in pp0:in pp3:in -! rlv0:in rlv3:in ww0:in ww3:in bcdata:in *bcdata.norm:in +! rlv0:in rlv3:in ww0:in ww3:in subroutine bcsymm2ndhalo_d(nn) ! bcsymm2ndhalo applies the symmetry boundary conditions to a ! block for the 2nd halo. this routine is separate as it makes @@ -310,9 +319,11 @@ subroutine bcsymm2ndhalo_d(nn) use constants use blockpointers, only : bcdata, bcdatad use flowvarrefstate, only : viscous, eddymodel + use inputphysics, only : useroughsa use bcpointers_d, only : gamma0, gamma3, ww0, ww0d, ww3, ww3d, pp0, & -& pp0d, pp3, pp3d, rlv0, rlv0d, rlv3, rlv3d, rev0, rev0d, rev3, rev3d,& -& istart, jstart, isize, jsize +& pp0d, pp3, pp3d, rlv0, rlv0d, rlv3, rlv3d, d2wall0, d2wall0d, & +& d2wall3, d2wall3d, ks0, ks3, rev0, rev0d, rev3, rev3d, istart, & +& jstart, isize, jsize implicit none ! subroutine arguments. integer(kind=inttype), intent(in) :: nn @@ -332,27 +343,22 @@ subroutine bcsymm2ndhalo_d(nn) temp = bcdata(nn)%norm(i, j, 1) temp0 = bcdata(nn)%norm(i, j, 2) temp1 = bcdata(nn)%norm(i, j, 3) - vnd = two*(temp*ww3d(i, j, ivx)+ww3(i, j, ivx)*bcdatad(nn)%norm(i& -& , j, 1)+temp0*ww3d(i, j, ivy)+ww3(i, j, ivy)*bcdatad(nn)%norm(i& -& , j, 2)+temp1*ww3d(i, j, ivz)+ww3(i, j, ivz)*bcdatad(nn)%norm(i& -& , j, 3)) - vn = two*(ww3(i, j, ivx)*temp+ww3(i, j, ivy)*temp0+ww3(i, j, ivz)*& -& temp1) + vnd = two*(temp*ww3d(i, j, ivx)+temp0*ww3d(i, j, ivy)+temp1*ww3d(i& +& , j, ivz)) + vn = two*(temp*ww3(i, j, ivx)+temp0*ww3(i, j, ivy)+temp1*ww3(i, j& +& , ivz)) ! determine the flow variables in the halo cell. ww0d(i, j, irho) = ww3d(i, j, irho) ww0(i, j, irho) = ww3(i, j, irho) temp1 = bcdata(nn)%norm(i, j, 1) - ww0d(i, j, ivx) = ww3d(i, j, ivx) - temp1*vnd - vn*bcdatad(nn)%& -& norm(i, j, 1) - ww0(i, j, ivx) = ww3(i, j, ivx) - vn*temp1 + ww0d(i, j, ivx) = ww3d(i, j, ivx) - temp1*vnd + ww0(i, j, ivx) = ww3(i, j, ivx) - temp1*vn temp1 = bcdata(nn)%norm(i, j, 2) - ww0d(i, j, ivy) = ww3d(i, j, ivy) - temp1*vnd - vn*bcdatad(nn)%& -& norm(i, j, 2) - ww0(i, j, ivy) = ww3(i, j, ivy) - vn*temp1 + ww0d(i, j, ivy) = ww3d(i, j, ivy) - temp1*vnd + ww0(i, j, ivy) = ww3(i, j, ivy) - temp1*vn temp1 = bcdata(nn)%norm(i, j, 3) - ww0d(i, j, ivz) = ww3d(i, j, ivz) - temp1*vnd - vn*bcdatad(nn)%& -& norm(i, j, 3) - ww0(i, j, ivz) = ww3(i, j, ivz) - vn*temp1 + ww0d(i, j, ivz) = ww3d(i, j, ivz) - temp1*vnd + ww0(i, j, ivz) = ww3(i, j, ivz) - temp1*vn ww0d(i, j, irhoe) = ww3d(i, j, irhoe) ww0(i, j, irhoe) = ww3(i, j, irhoe) ! set the pressure and gamma and possibly the @@ -360,6 +366,9 @@ subroutine bcsymm2ndhalo_d(nn) gamma0(i, j) = gamma3(i, j) pp0d(i, j) = pp3d(i, j) pp0(i, j) = pp3(i, j) + d2wall0d(i, j) = 0.0_8 + d2wall0(i, j) = d2wall3(i, j) + if (useroughsa) ks0(i, j) = ks3(i, j) if (viscous) then rlv0d(i, j) = rlv3d(i, j) rlv0(i, j) = rlv3(i, j) @@ -378,8 +387,10 @@ subroutine bcsymm2ndhalo(nn) use constants use blockpointers, only : bcdata use flowvarrefstate, only : viscous, eddymodel + use inputphysics, only : useroughsa use bcpointers_d, only : gamma0, gamma3, ww0, ww3, pp0, pp3, rlv0, & -& rlv3, rev0, rev3, istart, jstart, isize, jsize +& rlv3, d2wall0, d2wall3, ks0, ks3, rev0, rev3, istart, jstart, isize,& +& jsize implicit none ! subroutine arguments. integer(kind=inttype), intent(in) :: nn @@ -406,19 +417,23 @@ subroutine bcsymm2ndhalo(nn) ! laminar and eddy viscosity in the halo. gamma0(i, j) = gamma3(i, j) pp0(i, j) = pp3(i, j) + d2wall0(i, j) = d2wall3(i, j) + if (useroughsa) ks0(i, j) = ks3(i, j) if (viscous) rlv0(i, j) = rlv3(i, j) if (eddymodel) rev0(i, j) = rev3(i, j) end do end subroutine bcsymm2ndhalo ! differentiation of bcsymmpolar1sthalo in forward (tangent) mode (with options i4 dr8 r8): -! variations of useful results: *rev1 *pp1 *rlv1 *ww1 -! with respect to varying inputs: *xx *rev1 *rev2 *pp1 *pp2 *rlv1 -! *rlv2 *ww1 *ww2 -! rw status of diff variables: *xx:in *rev1:in-out *rev2:in *pp1:in-out -! *pp2:in *rlv1:in-out *rlv2:in *ww1:in-out *ww2:in -! plus diff mem management of: xx:in rev1:in rev2:in pp1:in pp2:in -! rlv1:in rlv2:in ww1:in ww2:in +! variations of useful results: *rev1 *d2wall1 *pp1 *rlv1 *ww1 +! with respect to varying inputs: *xx *rev1 *rev2 *d2wall1 *d2wall2 +! *pp1 *pp2 *rlv1 *rlv2 *ww1 *ww2 +! rw status of diff variables: *xx:in *rev1:in-out *rev2:in *d2wall1:in-out +! *d2wall2:in *pp1:in-out *pp2:in *rlv1:in-out *rlv2:in +! *ww1:in-out *ww2:in +! plus diff mem management of: xx:in rev1:in rev2:in d2wall1:in +! d2wall2:in pp1:in pp2:in rlv1:in rlv2:in ww1:in +! ww2:in subroutine bcsymmpolar1sthalo_d(nn) ! bcsymmpolar applies the polar symmetry boundary conditions to a ! singular line of a block. it is assumed that the pointers in @@ -427,9 +442,10 @@ subroutine bcsymmpolar1sthalo_d(nn) ! case of a degenerate line, as this line is the axi-symmetric ! centerline. this routine does just the 1st level halo. use constants + use inputphysics, only : useroughsa use bcpointers_d, only : ww1, ww1d, ww2, ww2d, pp1, pp1d, pp2, pp2d,& & rlv1, rlv1d, rlv2, rlv2d, rev1, rev1d, rev2, rev2d, xx, xxd, istart,& -& jstart, isize, jsize +& jstart, isize, jsize, d2wall1, d2wall1d, d2wall2, d2wall2d, ks1, ks2 use flowvarrefstate, only : viscous, eddymodel implicit none ! subroutine arguments. @@ -514,6 +530,9 @@ subroutine bcsymmpolar1sthalo_d(nn) ! eddy viscosity in the halo. pp1d(i, j) = pp2d(i, j) pp1(i, j) = pp2(i, j) + d2wall1d(i, j) = d2wall2d(i, j) + d2wall1(i, j) = d2wall2(i, j) + if (useroughsa) ks1(i, j) = ks2(i, j) if (viscous) then rlv1d(i, j) = rlv2d(i, j) rlv1(i, j) = rlv2(i, j) @@ -533,8 +552,9 @@ subroutine bcsymmpolar1sthalo(nn) ! case of a degenerate line, as this line is the axi-symmetric ! centerline. this routine does just the 1st level halo. use constants + use inputphysics, only : useroughsa use bcpointers_d, only : ww1, ww2, pp1, pp2, rlv1, rlv2, rev1, rev2,& -& xx, istart, jstart, isize, jsize +& xx, istart, jstart, isize, jsize, d2wall1, d2wall2, ks1, ks2 use flowvarrefstate, only : viscous, eddymodel implicit none ! subroutine arguments. @@ -590,19 +610,23 @@ subroutine bcsymmpolar1sthalo(nn) ! set the pressure and possibly the laminar and ! eddy viscosity in the halo. pp1(i, j) = pp2(i, j) + d2wall1(i, j) = d2wall2(i, j) + if (useroughsa) ks1(i, j) = ks2(i, j) if (viscous) rlv1(i, j) = rlv2(i, j) if (eddymodel) rev1(i, j) = rev2(i, j) end do end subroutine bcsymmpolar1sthalo ! differentiation of bcsymmpolar2ndhalo in forward (tangent) mode (with options i4 dr8 r8): -! variations of useful results: *rev0 *pp0 *rlv0 *ww0 -! with respect to varying inputs: *xx *rev0 *rev3 *pp0 *pp3 *rlv0 -! *rlv3 *ww0 *ww3 -! rw status of diff variables: *xx:in *rev0:in-out *rev3:in *pp0:in-out -! *pp3:in *rlv0:in-out *rlv3:in *ww0:in-out *ww3:in -! plus diff mem management of: xx:in rev0:in rev3:in pp0:in pp3:in -! rlv0:in rlv3:in ww0:in ww3:in +! variations of useful results: *rev0 *d2wall0 *pp0 *rlv0 *ww0 +! with respect to varying inputs: *xx *rev0 *d2wall0 *rev3 *d2wall3 +! *pp0 *pp3 *rlv0 *rlv3 *ww0 *ww3 +! rw status of diff variables: *xx:in *rev0:in-out *d2wall0:in-out +! *rev3:in *d2wall3:in *pp0:in-out *pp3:in *rlv0:in-out +! *rlv3:in *ww0:in-out *ww3:in +! plus diff mem management of: xx:in rev0:in d2wall0:in rev3:in +! d2wall3:in pp0:in pp3:in rlv0:in rlv3:in ww0:in +! ww3:in subroutine bcsymmpolar2ndhalo_d(nn) ! bcsymmpolar applies the polar symmetry boundary conditions to a ! singular line of a block. it is assumed that the pointers in @@ -611,9 +635,11 @@ subroutine bcsymmpolar2ndhalo_d(nn) ! case of a degenerate line, as this line is the axi-symmetric ! centerline. this routine does just the 2nd level halo. use constants + use inputphysics, only : useroughsa use bcpointers_d, only : ww0, ww0d, ww3, ww3d, pp0, pp0d, pp3, pp3d,& -& rlv0, rlv0d, rlv3, rlv3d, rev0, rev0d, rev3, rev3d, xx, xxd, istart,& -& jstart, isize, jsize +& rlv0, rlv0d, rlv3, rlv3d, rev0, rev0d, rev3, rev3d, d2wall0, & +& d2wall0d, d2wall3, d2wall3d, ks0, ks3, xx, xxd, istart, jstart, & +& isize, jsize use flowvarrefstate, only : viscous, eddymodel implicit none ! subroutine arguments. @@ -696,6 +722,9 @@ subroutine bcsymmpolar2ndhalo_d(nn) ! eddy viscosity in the halo. pp0d(i, j) = pp3d(i, j) pp0(i, j) = pp3(i, j) + d2wall0d(i, j) = d2wall3d(i, j) + d2wall0(i, j) = d2wall3(i, j) + if (useroughsa) ks0(i, j) = ks3(i, j) if (viscous) then rlv0d(i, j) = rlv3d(i, j) rlv0(i, j) = rlv3(i, j) @@ -715,8 +744,9 @@ subroutine bcsymmpolar2ndhalo(nn) ! case of a degenerate line, as this line is the axi-symmetric ! centerline. this routine does just the 2nd level halo. use constants + use inputphysics, only : useroughsa use bcpointers_d, only : ww0, ww3, pp0, pp3, rlv0, rlv3, rev0, rev3,& -& xx, istart, jstart, isize, jsize +& d2wall0, d2wall3, ks0, ks3, xx, istart, jstart, isize, jsize use flowvarrefstate, only : viscous, eddymodel implicit none ! subroutine arguments. @@ -770,6 +800,8 @@ subroutine bcsymmpolar2ndhalo(nn) ! set the pressure and possibly the laminar and ! eddy viscosity in the halo. pp0(i, j) = pp3(i, j) + d2wall0(i, j) = d2wall3(i, j) + if (useroughsa) ks0(i, j) = ks3(i, j) if (viscous) rlv0(i, j) = rlv3(i, j) if (eddymodel) rev0(i, j) = rev3(i, j) end do diff --git a/src/adjoint/outputForward/sa_d.f90 b/src/adjoint/outputForward/sa_d.f90 index 7d076aa76..c97a02d0e 100644 --- a/src/adjoint/outputForward/sa_d.f90 +++ b/src/adjoint/outputForward/sa_d.f90 @@ -40,6 +40,8 @@ subroutine sasource_d() real(kind=realtype), parameter :: f23=two*third ! local variables. integer(kind=inttype) :: i, j, k, nn, ii + real(kind=realtype) :: distrough + real(kind=realtype) :: distroughd real(kind=realtype) :: fv1, fv2, ft2 real(kind=realtype) :: fv1d, fv2d, ft2d real(kind=realtype) :: ss, sst, nu, dist2inv, chi, chi2, chi3 @@ -363,12 +365,22 @@ subroutine sasource_d() temp9 = rlv(i, j, k)/temp10 nud = (rlvd(i, j, k)-temp9*wd(i, j, k, irho))/temp10 nu = temp9 - temp10 = one/(d2wall(i, j, k)*d2wall(i, j, k)) - dist2invd = -(temp10*2*d2walld(i, j, k)/d2wall(i, j, k)) - dist2inv = temp10 temp10 = w(i, j, k, itu1)/nu chid = (wd(i, j, k, itu1)-temp10*nud)/nu chi = temp10 + if (.not.useroughsa) then + temp10 = one/(d2wall(i, j, k)*d2wall(i, j, k)) + dist2invd = -(temp10*2*d2walld(i, j, k)/d2wall(i, j, k)) + dist2inv = temp10 + else + distroughd = d2walld(i, j, k) + distrough = d2wall(i, j, k) + 0.03_realtype*ks(i, j, k) + temp10 = one/(distrough*distrough) + dist2invd = -(temp10*2*distroughd/distrough) + dist2inv = temp10 + chid = chid - ks(i, j, k)*rsacr1*distroughd/distrough**2 + chi = chi + rsacr1*ks(i, j, k)/distrough + end if chi2d = 2*chi*chid chi2 = chi*chi chi3d = chi2*chid + chi*chi2d @@ -376,9 +388,17 @@ subroutine sasource_d() temp10 = chi3/(cv13+chi3) fv1d = (1.0-temp10)*chi3d/(cv13+chi3) fv1 = temp10 - temp10 = chi/(one+chi*fv1) - fv2d = -((chid-temp10*(fv1*chid+chi*fv1d))/(one+chi*fv1)) - fv2 = one - temp10 + if (.not.useroughsa) then + temp10 = chi/(one+chi*fv1) + fv2d = -((chid-temp10*(fv1*chid+chi*fv1d))/(one+chi*fv1)) + fv2 = one - temp10 + else + temp10 = w(i, j, k, itu1) + temp9 = w(i, j, k, itu1)/(nu+temp10*fv1) + fv2d = -((wd(i, j, k, itu1)-temp9*(nud+fv1*wd(i, j, k, & +& itu1)+temp10*fv1d))/(nu+temp10*fv1)) + fv2 = one - temp9 + end if ! the function ft2, which is designed to keep a laminar ! solution laminar. when running in fully turbulent mode ! this function should be set to 0.0. @@ -491,6 +511,7 @@ subroutine sasource() real(kind=realtype), parameter :: f23=two*third ! local variables. integer(kind=inttype) :: i, j, k, nn, ii + real(kind=realtype) :: distrough real(kind=realtype) :: fv1, fv2, ft2 real(kind=realtype) :: ss, sst, nu, dist2inv, chi, chi2, chi3 real(kind=realtype) :: rr, gg, gg6, termfw, fwsa, term1, term2 @@ -604,12 +625,22 @@ subroutine sasource() ! and nu) and the functions fv1 and fv2. the latter corrects ! the production term near a viscous wall. nu = rlv(i, j, k)/w(i, j, k, irho) - dist2inv = one/d2wall(i, j, k)**2 chi = w(i, j, k, itu1)/nu + if (.not.useroughsa) then + dist2inv = one/d2wall(i, j, k)**2 + else + distrough = d2wall(i, j, k) + 0.03_realtype*ks(i, j, k) + dist2inv = one/distrough**2 + chi = chi + rsacr1*ks(i, j, k)/distrough + end if chi2 = chi*chi chi3 = chi*chi2 fv1 = chi3/(chi3+cv13) - fv2 = one - chi/(one+chi*fv1) + if (.not.useroughsa) then + fv2 = one - chi/(one+chi*fv1) + else + fv2 = one - w(i, j, k, itu1)/(nu+w(i, j, k, itu1)*fv1) + end if ! the function ft2, which is designed to keep a laminar ! solution laminar. when running in fully turbulent mode ! this function should be set to 0.0. diff --git a/src/adjoint/outputForward/turbBCRoutines_d.f90 b/src/adjoint/outputForward/turbBCRoutines_d.f90 index 6f41ad314..758cddfd9 100644 --- a/src/adjoint/outputForward/turbBCRoutines_d.f90 +++ b/src/adjoint/outputForward/turbBCRoutines_d.f90 @@ -7,12 +7,16 @@ module turbbcroutines_d contains ! differentiation of applyallturbbcthisblock in forward (tangent) mode (with options i4 dr8 r8): ! variations of useful results: *rev *w -! with respect to varying inputs: *rev *bvtj1 *bvtj2 *w *bvtk1 -! *bvtk2 *bvti1 *bvti2 +! with respect to varying inputs: *rev *bvtj1 *bvtj2 *w *bmtk1 +! *bmtk2 *bvtk1 *bvtk2 *d2wall *bmti1 *bmti2 *bvti1 +! *bvti2 *bmtj1 *bmtj2 ! rw status of diff variables: *rev:in-out *bvtj1:in *bvtj2:in -! *w:in-out *bvtk1:in *bvtk2:in *bvti1:in *bvti2:in +! *w:in-out *bmtk1:in *bmtk2:in *bvtk1:in *bvtk2:in +! *d2wall:in *bmti1:in *bmti2:in *bvti1:in *bvti2:in +! *bmtj1:in *bmtj2:in ! plus diff mem management of: rev:in bvtj1:in bvtj2:in w:in -! bvtk1:in bvtk2:in bvti1:in bvti2:in +! bmtk1:in bmtk2:in bvtk1:in bvtk2:in d2wall:in +! bmti1:in bmti2:in bvti1:in bvti2:in bmtj1:in bmtj2:in ! ================================================================== subroutine applyallturbbcthisblock_d(secondhalo) ! @@ -36,6 +40,7 @@ subroutine applyallturbbcthisblock_d(secondhalo) real(kind=realtype), dimension(:, :, :, :), pointer :: bmt real(kind=realtype), dimension(:, :, :), pointer :: bvt, ww1, ww2 real(kind=realtype) :: temp + real(kind=realtype) :: temp0 ! loop over the boundary condition subfaces of this block. bocos:do nn=1,nbocos ! loop over the faces and set the state in @@ -49,9 +54,11 @@ subroutine applyallturbbcthisblock_d(secondhalo) wd(1, i, j, l) = bvti1d(i, j, l) w(1, i, j, l) = bvti1(i, j, l) do m=nt1,nt2 - temp = bmti1(i, j, l, m) - wd(1, i, j, l) = wd(1, i, j, l) - temp*wd(2, i, j, m) - w(1, i, j, l) = w(1, i, j, l) - temp*w(2, i, j, m) + temp = w(2, i, j, m) + temp0 = bmti1(i, j, l, m) + wd(1, i, j, l) = wd(1, i, j, l) - temp*bmti1d(i, j, l& +& , m) - temp0*wd(2, i, j, m) + w(1, i, j, l) = w(1, i, j, l) - temp0*temp end do end do end do @@ -63,10 +70,11 @@ subroutine applyallturbbcthisblock_d(secondhalo) wd(ie, i, j, l) = bvti2d(i, j, l) w(ie, i, j, l) = bvti2(i, j, l) do m=nt1,nt2 + temp0 = w(il, i, j, m) temp = bmti2(i, j, l, m) - wd(ie, i, j, l) = wd(ie, i, j, l) - temp*wd(il, i, j, & -& m) - w(ie, i, j, l) = w(ie, i, j, l) - temp*w(il, i, j, m) + wd(ie, i, j, l) = wd(ie, i, j, l) - temp0*bmti2d(i, j& +& , l, m) - temp*wd(il, i, j, m) + w(ie, i, j, l) = w(ie, i, j, l) - temp*temp0 end do end do end do @@ -78,9 +86,11 @@ subroutine applyallturbbcthisblock_d(secondhalo) wd(i, 1, j, l) = bvtj1d(i, j, l) w(i, 1, j, l) = bvtj1(i, j, l) do m=nt1,nt2 + temp0 = w(i, 2, j, m) temp = bmtj1(i, j, l, m) - wd(i, 1, j, l) = wd(i, 1, j, l) - temp*wd(i, 2, j, m) - w(i, 1, j, l) = w(i, 1, j, l) - temp*w(i, 2, j, m) + wd(i, 1, j, l) = wd(i, 1, j, l) - temp0*bmtj1d(i, j, l& +& , m) - temp*wd(i, 2, j, m) + w(i, 1, j, l) = w(i, 1, j, l) - temp*temp0 end do end do end do @@ -92,10 +102,11 @@ subroutine applyallturbbcthisblock_d(secondhalo) wd(i, je, j, l) = bvtj2d(i, j, l) w(i, je, j, l) = bvtj2(i, j, l) do m=nt1,nt2 + temp0 = w(i, jl, j, m) temp = bmtj2(i, j, l, m) - wd(i, je, j, l) = wd(i, je, j, l) - temp*wd(i, jl, j, & -& m) - w(i, je, j, l) = w(i, je, j, l) - temp*w(i, jl, j, m) + wd(i, je, j, l) = wd(i, je, j, l) - temp0*bmtj2d(i, j& +& , l, m) - temp*wd(i, jl, j, m) + w(i, je, j, l) = w(i, je, j, l) - temp*temp0 end do end do end do @@ -107,9 +118,11 @@ subroutine applyallturbbcthisblock_d(secondhalo) wd(i, j, 1, l) = bvtk1d(i, j, l) w(i, j, 1, l) = bvtk1(i, j, l) do m=nt1,nt2 + temp0 = w(i, j, 2, m) temp = bmtk1(i, j, l, m) - wd(i, j, 1, l) = wd(i, j, 1, l) - temp*wd(i, j, 2, m) - w(i, j, 1, l) = w(i, j, 1, l) - temp*w(i, j, 2, m) + wd(i, j, 1, l) = wd(i, j, 1, l) - temp0*bmtk1d(i, j, l& +& , m) - temp*wd(i, j, 2, m) + w(i, j, 1, l) = w(i, j, 1, l) - temp*temp0 end do end do end do @@ -121,10 +134,11 @@ subroutine applyallturbbcthisblock_d(secondhalo) wd(i, j, ke, l) = bvtk2d(i, j, l) w(i, j, ke, l) = bvtk2(i, j, l) do m=nt1,nt2 + temp0 = w(i, j, kl, m) temp = bmtk2(i, j, l, m) - wd(i, j, ke, l) = wd(i, j, ke, l) - temp*wd(i, j, kl, & -& m) - w(i, j, ke, l) = w(i, j, ke, l) - temp*w(i, j, kl, m) + wd(i, j, ke, l) = wd(i, j, ke, l) - temp0*bmtk2d(i, j& +& , l, m) - temp*wd(i, j, kl, m) + w(i, j, ke, l) = w(i, j, ke, l) - temp*temp0 end do end do end do @@ -407,8 +421,8 @@ end subroutine bceddynowall ! differentiation of bceddywall in forward (tangent) mode (with options i4 dr8 r8): ! variations of useful results: *rev -! with respect to varying inputs: *rev -! plus diff mem management of: rev:in +! with respect to varying inputs: *rev *d2wall +! plus diff mem management of: rev:in d2wall:in subroutine bceddywall_d(nn) ! ! bceddywall sets the eddy viscosity in the halo cells of @@ -427,6 +441,8 @@ subroutine bceddywall_d(nn) ! local variables. ! integer(kind=inttype) :: i, j + real(kind=realtype) :: fact + real(kind=realtype) :: factd ! determine the face id on which the subface is located and ! loop over the faces of the subface and set the eddy viscosity ! in the halo cells. @@ -434,43 +450,49 @@ subroutine bceddywall_d(nn) case (imin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - revd(1, i, j) = -revd(2, i, j) - rev(1, i, j) = -rev(2, i, j) + call saroughfact_d(2, i, j, fact, factd) + revd(1, i, j) = rev(2, i, j)*factd + fact*revd(2, i, j) + rev(1, i, j) = fact*rev(2, i, j) end do end do case (imax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - revd(ie, i, j) = -revd(il, i, j) - rev(ie, i, j) = -rev(il, i, j) + call saroughfact_d(il, i, j, fact, factd) + revd(ie, i, j) = rev(il, i, j)*factd + fact*revd(il, i, j) + rev(ie, i, j) = fact*rev(il, i, j) end do end do case (jmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - revd(i, 1, j) = -revd(i, 2, j) - rev(i, 1, j) = -rev(i, 2, j) + call saroughfact_d(i, 2, j, fact, factd) + revd(i, 1, j) = rev(i, 2, j)*factd + fact*revd(i, 2, j) + rev(i, 1, j) = fact*rev(i, 2, j) end do end do case (jmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - revd(i, je, j) = -revd(i, jl, j) - rev(i, je, j) = -rev(i, jl, j) + call saroughfact_d(i, jl, j, fact, factd) + revd(i, je, j) = rev(i, jl, j)*factd + fact*revd(i, jl, j) + rev(i, je, j) = fact*rev(i, jl, j) end do end do case (kmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - revd(i, j, 1) = -revd(i, j, 2) - rev(i, j, 1) = -rev(i, j, 2) + call saroughfact_d(i, j, 2, fact, factd) + revd(i, j, 1) = rev(i, j, 2)*factd + fact*revd(i, j, 2) + rev(i, j, 1) = fact*rev(i, j, 2) end do end do case (kmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - revd(i, j, ke) = -revd(i, j, kl) - rev(i, j, ke) = -rev(i, j, kl) + call saroughfact_d(i, j, kl, fact, factd) + revd(i, j, ke) = rev(i, j, kl)*factd + fact*revd(i, j, kl) + rev(i, j, ke) = fact*rev(i, j, kl) end do end do end select @@ -494,6 +516,7 @@ subroutine bceddywall(nn) ! local variables. ! integer(kind=inttype) :: i, j + real(kind=realtype) :: fact ! determine the face id on which the subface is located and ! loop over the faces of the subface and set the eddy viscosity ! in the halo cells. @@ -501,49 +524,58 @@ subroutine bceddywall(nn) case (imin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(1, i, j) = -rev(2, i, j) + call saroughfact(2, i, j, fact) + rev(1, i, j) = fact*rev(2, i, j) end do end do case (imax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(ie, i, j) = -rev(il, i, j) + call saroughfact(il, i, j, fact) + rev(ie, i, j) = fact*rev(il, i, j) end do end do case (jmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(i, 1, j) = -rev(i, 2, j) + call saroughfact(i, 2, j, fact) + rev(i, 1, j) = fact*rev(i, 2, j) end do end do case (jmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(i, je, j) = -rev(i, jl, j) + call saroughfact(i, jl, j, fact) + rev(i, je, j) = fact*rev(i, jl, j) end do end do case (kmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(i, j, 1) = -rev(i, j, 2) + call saroughfact(i, j, 2, fact) + rev(i, j, 1) = fact*rev(i, j, 2) end do end do case (kmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(i, j, ke) = -rev(i, j, kl) + call saroughfact(i, j, kl, fact) + rev(i, j, ke) = fact*rev(i, j, kl) end do end do end select end subroutine bceddywall ! differentiation of bcturbfarfield in forward (tangent) mode (with options i4 dr8 r8): -! variations of useful results: *bvtj1 *bvtj2 *bvtk1 *bvtk2 -! *bvti1 *bvti2 -! with respect to varying inputs: winf *bvtj1 *bvtj2 *bvtk1 *bvtk2 -! *bvti1 *bvti2 -! plus diff mem management of: bvtj1:in bvtj2:in bvtk1:in bvtk2:in -! bvti1:in bvti2:in +! variations of useful results: *bvtj1 *bvtj2 *bmtk1 *bmtk2 +! *bvtk1 *bvtk2 *bmti1 *bmti2 *bvti1 *bvti2 *bmtj1 +! *bmtj2 +! with respect to varying inputs: winf *bvtj1 *bvtj2 *bmtk1 *bmtk2 +! *bvtk1 *bvtk2 *bmti1 *bmti2 *bvti1 *bvti2 *bmtj1 +! *bmtj2 +! plus diff mem management of: bvtj1:in bvtj2:in bmtk1:in bmtk2:in +! bvtk1:in bvtk2:in bmti1:in bmti2:in bvti1:in bvti2:in +! bmtj1:in bmtj2:in subroutine bcturbfarfield_d(nn) ! ! bcturbfarfield applies the implicit treatment of the @@ -584,16 +616,22 @@ subroutine bcturbfarfield_d(nn) do l=nt1,nt2 select case (bcfaceid(nn)) case (imin) + bmti1d(i, j, l, l) = 0.0_8 bmti1(i, j, l, l) = -one case (imax) + bmti2d(i, j, l, l) = 0.0_8 bmti2(i, j, l, l) = -one case (jmin) + bmtj1d(i, j, l, l) = 0.0_8 bmtj1(i, j, l, l) = -one case (jmax) + bmtj2d(i, j, l, l) = 0.0_8 bmtj2(i, j, l, l) = -one case (kmin) + bmtk1d(i, j, l, l) = 0.0_8 bmtk1(i, j, l, l) = -one case (kmax) + bmtk2d(i, j, l, l) = 0.0_8 bmtk2(i, j, l, l) = -one end select end do @@ -908,6 +946,65 @@ subroutine bcturboutflow(nn) end do end subroutine bcturboutflow +! differentiation of bcturbsymm in forward (tangent) mode (with options i4 dr8 r8): +! variations of useful results: *bmtk1 *bmtk2 *bmti1 *bmti2 +! *bmtj1 *bmtj2 +! with respect to varying inputs: *bmtk1 *bmtk2 *bmti1 *bmti2 +! *bmtj1 *bmtj2 +! plus diff mem management of: bmtk1:in bmtk2:in bmti1:in bmti2:in +! bmtj1:in bmtj2:in + subroutine bcturbsymm_d(nn) +! +! bcturbsymm applies the implicit treatment of the symmetry +! boundary condition (or inviscid wall) to subface nn. as the +! symmetry boundary condition is independent of the turbulence +! model, this routine is valid for all models. it is assumed +! that the pointers in blockpointers are already set to the +! correct block on the correct grid level. +! + use constants + use blockpointers + use flowvarrefstate + implicit none +! +! subroutine arguments. +! + integer(kind=inttype), intent(in) :: nn +! +! local variables. +! + integer(kind=inttype) :: i, j, l +! loop over the faces of the subfaces and set the values of bmt +! for an implicit treatment. for a symmetry face this means +! that the halo value is set to the internal value. + do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend + do i=bcdata(nn)%icbeg,bcdata(nn)%icend + do l=nt1,nt2 + select case (bcfaceid(nn)) + case (imin) + bmti1d(i, j, l, l) = 0.0_8 + bmti1(i, j, l, l) = -one + case (imax) + bmti2d(i, j, l, l) = 0.0_8 + bmti2(i, j, l, l) = -one + case (jmin) + bmtj1d(i, j, l, l) = 0.0_8 + bmtj1(i, j, l, l) = -one + case (jmax) + bmtj2d(i, j, l, l) = 0.0_8 + bmtj2(i, j, l, l) = -one + case (kmin) + bmtk1d(i, j, l, l) = 0.0_8 + bmtk1(i, j, l, l) = -one + case (kmax) + bmtk2d(i, j, l, l) = 0.0_8 + bmtk2(i, j, l, l) = -one + end select + end do + end do + end do + end subroutine bcturbsymm_d + subroutine bcturbsymm(nn) ! ! bcturbsymm applies the implicit treatment of the symmetry @@ -955,14 +1052,19 @@ subroutine bcturbsymm(nn) end subroutine bcturbsymm ! differentiation of bcturbtreatment in forward (tangent) mode (with options i4 dr8 r8): -! variations of useful results: *bvtj1 *bvtj2 *bvtk1 *bvtk2 -! *bvti1 *bvti2 -! with respect to varying inputs: winf *w *rlv *d2wall -! rw status of diff variables: winf:in *bvtj1:out *bvtj2:out -! *w:in *rlv:in *bvtk1:out *bvtk2:out *d2wall:in -! *bvti1:out *bvti2:out -! plus diff mem management of: bvtj1:in bvtj2:in w:in rlv:in -! bvtk1:in bvtk2:in d2wall:in bvti1:in bvti2:in +! variations of useful results: *bvtj1 *bvtj2 *bmtk1 *bmtk2 +! *bvtk1 *bvtk2 *bmti1 *bmti2 *bvti1 *bvti2 *bmtj1 +! *bmtj2 +! with respect to varying inputs: winf *bvtj1 *bvtj2 *w *bmtk1 +! *rlv *bmtk2 *bvtk1 *bvtk2 *d2wall *bmti1 *bmti2 +! *bvti1 *bvti2 *bmtj1 *bmtj2 +! rw status of diff variables: winf:in *bvtj1:in-out *bvtj2:in-out +! *w:in *bmtk1:in-out *rlv:in *bmtk2:in-out *bvtk1:in-out +! *bvtk2:in-out *d2wall:in *bmti1:in-out *bmti2:in-out +! *bvti1:in-out *bvti2:in-out *bmtj1:in-out *bmtj2:in-out +! plus diff mem management of: bvtj1:in bvtj2:in w:in bmtk1:in +! rlv:in bmtk2:in bvtk1:in bvtk2:in d2wall:in bmti1:in +! bmti2:in bvti1:in bvti2:in bmtj1:in bmtj2:in subroutine bcturbtreatment_d() ! ! bcturbtreatment sets the arrays bmti1, bvti1, etc, such that @@ -991,7 +1093,9 @@ subroutine bcturbtreatment_d() do j=1,je do l=nt1,nt2 do m=nt1,nt2 + bmti1d(j, k, l, m) = 0.0_8 bmti1(j, k, l, m) = zero + bmti2d(j, k, l, m) = 0.0_8 bmti2(j, k, l, m) = zero end do bvti1d(j, k, l) = 0.0_8 @@ -1005,7 +1109,9 @@ subroutine bcturbtreatment_d() do i=1,ie do l=nt1,nt2 do m=nt1,nt2 + bmtj1d(i, k, l, m) = 0.0_8 bmtj1(i, k, l, m) = zero + bmtj2d(i, k, l, m) = 0.0_8 bmtj2(i, k, l, m) = zero end do bvtj1d(i, k, l) = 0.0_8 @@ -1019,7 +1125,9 @@ subroutine bcturbtreatment_d() do i=1,ie do l=nt1,nt2 do m=nt1,nt2 + bmtk1d(i, j, l, m) = 0.0_8 bmtk1(i, j, l, m) = zero + bmtk2d(i, j, l, m) = 0.0_8 bmtk2(i, j, l, m) = zero end do bvtk1d(i, j, l) = 0.0_8 @@ -1029,12 +1137,6 @@ subroutine bcturbtreatment_d() end do end do end do - if (associated(bvtj1d)) bvtj1d = 0.0_8 - if (associated(bvtj2d)) bvtj2d = 0.0_8 - if (associated(bvtk1d)) bvtk1d = 0.0_8 - if (associated(bvtk2d)) bvtk2d = 0.0_8 - if (associated(bvti1d)) bvti1d = 0.0_8 - if (associated(bvti2d)) bvti2d = 0.0_8 ! loop over the boundary condition subfaces of this block. bocos:do nn=1,nbocos ! determine the kind of boundary condition for this subface. @@ -1049,7 +1151,7 @@ subroutine bcturbtreatment_d() case (symm, symmpolar, eulerwall) ! symmetry, polar symmetry or inviscid wall. treatment of ! the turbulent equations is identical. - call bcturbsymm(nn) + call bcturbsymm_d(nn) !============================================================= case (farfield) ! farfield. the kind of boundary condition to be applied, @@ -1160,12 +1262,15 @@ subroutine bcturbtreatment() end subroutine bcturbtreatment ! differentiation of bcturbwall in forward (tangent) mode (with options i4 dr8 r8): -! variations of useful results: *bvtj1 *bvtj2 *bvtk1 *bvtk2 -! *bvti1 *bvti2 -! with respect to varying inputs: *bvtj1 *bvtj2 *w *rlv *bvtk1 -! *bvtk2 *d2wall *bvti1 *bvti2 -! plus diff mem management of: bvtj1:in bvtj2:in w:in rlv:in -! bvtk1:in bvtk2:in d2wall:in bvti1:in bvti2:in +! variations of useful results: *bvtj1 *bvtj2 *bmtk1 *bmtk2 +! *bvtk1 *bvtk2 *bmti1 *bmti2 *bvti1 *bvti2 *bmtj1 +! *bmtj2 +! with respect to varying inputs: *bvtj1 *bvtj2 *w *bmtk1 *rlv +! *bmtk2 *bvtk1 *bvtk2 *d2wall *bmti1 *bmti2 *bvti1 +! *bvti2 *bmtj1 *bmtj2 +! plus diff mem management of: bvtj1:in bvtj2:in w:in bmtk1:in +! rlv:in bmtk2:in bvtk1:in bvtk2:in d2wall:in bmti1:in +! bmti2:in bvti1:in bvti2:in bmtj1:in bmtj2:in subroutine bcturbwall_d(nn) ! ! bcturbwall applies the implicit treatment of the viscous @@ -1188,8 +1293,8 @@ subroutine bcturbwall_d(nn) ! local variables. ! integer(kind=inttype) :: i, j, ii, jj, iimax, jjmax - real(kind=realtype) :: tmpd, tmpe, tmpf, nu - real(kind=realtype) :: tmpdd, nud + real(kind=realtype) :: tmpd, tmpe, tmpf, nu, fact + real(kind=realtype) :: tmpdd, nud, factd real(kind=realtype), dimension(:, :, :, :), pointer :: bmt real(kind=realtype), dimension(:, :, :), pointer :: bvt, ww2 real(kind=realtype), dimension(:, :), pointer :: rlv2, dd2wall @@ -1220,37 +1325,49 @@ subroutine bcturbwall_d(nn) case (imin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmti1(i, j, itu1, itu1) = one + call saroughfact_d(2, i, j, fact, factd) + bmti1d(i, j, itu1, itu1) = -factd + bmti1(i, j, itu1, itu1) = -fact end do end do case (imax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmti2(i, j, itu1, itu1) = one + call saroughfact_d(il, i, j, fact, factd) + bmti2d(i, j, itu1, itu1) = -factd + bmti2(i, j, itu1, itu1) = -fact end do end do case (jmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtj1(i, j, itu1, itu1) = one + call saroughfact_d(i, 2, j, fact, factd) + bmtj1d(i, j, itu1, itu1) = -factd + bmtj1(i, j, itu1, itu1) = -fact end do end do case (jmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtj2(i, j, itu1, itu1) = one + call saroughfact_d(i, jl, j, fact, factd) + bmtj2d(i, j, itu1, itu1) = -factd + bmtj2(i, j, itu1, itu1) = -fact end do end do case (kmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtk1(i, j, itu1, itu1) = one + call saroughfact_d(i, j, 2, fact, factd) + bmtk1d(i, j, itu1, itu1) = -factd + bmtk1(i, j, itu1, itu1) = -fact end do end do case (kmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtk2(i, j, itu1, itu1) = one + call saroughfact_d(i, j, kl, fact, factd) + bmtk2d(i, j, itu1, itu1) = -factd + bmtk2(i, j, itu1, itu1) = -fact end do end do end select @@ -1299,7 +1416,9 @@ subroutine bcturbwall_d(nn) temp0 = one/(rkwbeta1*(d2wall(2, ii, jj)*d2wall(2, ii, jj))) tmpdd = -(temp0*2*d2walld(2, ii, jj)/d2wall(2, ii, jj)) tmpd = temp0 + bmti1d(i, j, itu1, itu1) = 0.0_8 bmti1(i, j, itu1, itu1) = one + bmti1d(i, j, itu2, itu2) = 0.0_8 bmti1(i, j, itu2, itu2) = one bvti1d(i, j, itu2) = two*60.0_realtype*(tmpd*nud+nu*tmpdd) bvti1(i, j, itu2) = two*60.0_realtype*nu*tmpd @@ -1338,7 +1457,9 @@ subroutine bcturbwall_d(nn) & )) tmpdd = -(temp0*2*d2walld(il, ii, jj)/d2wall(il, ii, jj)) tmpd = temp0 + bmti2d(i, j, itu1, itu1) = 0.0_8 bmti2(i, j, itu1, itu1) = one + bmti2d(i, j, itu2, itu2) = 0.0_8 bmti2(i, j, itu2, itu2) = one bvti2d(i, j, itu2) = two*60.0_realtype*(tmpd*nud+nu*tmpdd) bvti2(i, j, itu2) = two*60.0_realtype*nu*tmpd @@ -1376,7 +1497,9 @@ subroutine bcturbwall_d(nn) temp0 = one/(rkwbeta1*(d2wall(ii, 2, jj)*d2wall(ii, 2, jj))) tmpdd = -(temp0*2*d2walld(ii, 2, jj)/d2wall(ii, 2, jj)) tmpd = temp0 + bmtj1d(i, j, itu1, itu1) = 0.0_8 bmtj1(i, j, itu1, itu1) = one + bmtj1d(i, j, itu2, itu2) = 0.0_8 bmtj1(i, j, itu2, itu2) = one bvtj1d(i, j, itu2) = two*60.0_realtype*(tmpd*nud+nu*tmpdd) bvtj1(i, j, itu2) = two*60.0_realtype*nu*tmpd @@ -1415,7 +1538,9 @@ subroutine bcturbwall_d(nn) & )) tmpdd = -(temp0*2*d2walld(ii, jl, jj)/d2wall(ii, jl, jj)) tmpd = temp0 + bmtj2d(i, j, itu1, itu1) = 0.0_8 bmtj2(i, j, itu1, itu1) = one + bmtj2d(i, j, itu2, itu2) = 0.0_8 bmtj2(i, j, itu2, itu2) = one bvtj2d(i, j, itu2) = two*60.0_realtype*(tmpd*nud+nu*tmpdd) bvtj2(i, j, itu2) = two*60.0_realtype*nu*tmpd @@ -1453,7 +1578,9 @@ subroutine bcturbwall_d(nn) temp0 = one/(rkwbeta1*(d2wall(ii, jj, 2)*d2wall(ii, jj, 2))) tmpdd = -(temp0*2*d2walld(ii, jj, 2)/d2wall(ii, jj, 2)) tmpd = temp0 + bmtk1d(i, j, itu1, itu1) = 0.0_8 bmtk1(i, j, itu1, itu1) = one + bmtk1d(i, j, itu2, itu2) = 0.0_8 bmtk1(i, j, itu2, itu2) = one bvtk1d(i, j, itu2) = two*60.0_realtype*(tmpd*nud+nu*tmpdd) bvtk1(i, j, itu2) = two*60.0_realtype*nu*tmpd @@ -1492,7 +1619,9 @@ subroutine bcturbwall_d(nn) & )) tmpdd = -(temp0*2*d2walld(ii, jj, kl)/d2wall(ii, jj, kl)) tmpd = temp0 + bmtk2d(i, j, itu1, itu1) = 0.0_8 bmtk2(i, j, itu1, itu1) = one + bmtk2d(i, j, itu2, itu2) = 0.0_8 bmtk2(i, j, itu2, itu2) = one bvtk2d(i, j, itu2) = two*60.0_realtype*(tmpd*nud+nu*tmpdd) bvtk2(i, j, itu2) = two*60.0_realtype*nu*tmpd @@ -1507,42 +1636,54 @@ subroutine bcturbwall_d(nn) case (imin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend + bmti1d(i, j, itu1, itu1) = 0.0_8 bmti1(i, j, itu1, itu1) = one + bmti1d(i, j, itu2, itu2) = 0.0_8 bmti1(i, j, itu2, itu2) = one end do end do case (imax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend + bmti2d(i, j, itu1, itu1) = 0.0_8 bmti2(i, j, itu1, itu1) = one + bmti2d(i, j, itu2, itu2) = 0.0_8 bmti2(i, j, itu2, itu2) = one end do end do case (jmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend + bmtj1d(i, j, itu1, itu1) = 0.0_8 bmtj1(i, j, itu1, itu1) = one + bmtj1d(i, j, itu2, itu2) = 0.0_8 bmtj1(i, j, itu2, itu2) = one end do end do case (jmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend + bmtj2d(i, j, itu1, itu1) = 0.0_8 bmtj2(i, j, itu1, itu1) = one + bmtj2d(i, j, itu2, itu2) = 0.0_8 bmtj2(i, j, itu2, itu2) = one end do end do case (kmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend + bmtk1d(i, j, itu1, itu1) = 0.0_8 bmtk1(i, j, itu1, itu1) = one + bmtk1d(i, j, itu2, itu2) = 0.0_8 bmtk1(i, j, itu2, itu2) = one end do end do case (kmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend + bmtk2d(i, j, itu1, itu1) = 0.0_8 bmtk2(i, j, itu1, itu1) = one + bmtk2d(i, j, itu2, itu2) = 0.0_8 bmtk2(i, j, itu2, itu2) = one end do end do @@ -1573,7 +1714,7 @@ subroutine bcturbwall(nn) ! local variables. ! integer(kind=inttype) :: i, j, ii, jj, iimax, jjmax - real(kind=realtype) :: tmpd, tmpe, tmpf, nu + real(kind=realtype) :: tmpd, tmpe, tmpf, nu, fact real(kind=realtype), dimension(:, :, :, :), pointer :: bmt real(kind=realtype), dimension(:, :, :), pointer :: bvt, ww2 real(kind=realtype), dimension(:, :), pointer :: rlv2, dd2wall @@ -1602,37 +1743,43 @@ subroutine bcturbwall(nn) case (imin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmti1(i, j, itu1, itu1) = one + call saroughfact(2, i, j, fact) + bmti1(i, j, itu1, itu1) = -fact end do end do case (imax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmti2(i, j, itu1, itu1) = one + call saroughfact(il, i, j, fact) + bmti2(i, j, itu1, itu1) = -fact end do end do case (jmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtj1(i, j, itu1, itu1) = one + call saroughfact(i, 2, j, fact) + bmtj1(i, j, itu1, itu1) = -fact end do end do case (jmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtj2(i, j, itu1, itu1) = one + call saroughfact(i, jl, j, fact) + bmtj2(i, j, itu1, itu1) = -fact end do end do case (kmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtk1(i, j, itu1, itu1) = one + call saroughfact(i, j, 2, fact) + bmtk1(i, j, itu1, itu1) = -fact end do end do case (kmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtk2(i, j, itu1, itu1) = one + call saroughfact(i, j, kl, fact) + bmtk2(i, j, itu1, itu1) = -fact end do end do end select @@ -2224,5 +2371,68 @@ subroutine turbbcnswall(secondhalo) end do bocos end subroutine turbbcnswall +! differentiation of saroughfact in forward (tangent) mode (with options i4 dr8 r8): +! variations of useful results: fact +! with respect to varying inputs: *d2wall +! plus diff mem management of: d2wall:in + subroutine saroughfact_d(i, j, k, fact, factd) +! returns either the regular sa-boundary condition +! or the modified roughness-boundary condition + use constants + use inputphysics, only : useroughsa + use blockpointers, only : ks, d2wall, d2walld, il, jl, kl + implicit none +! local variablse + integer(kind=inttype), intent(in) :: i, j, k + real(kind=realtype), intent(out) :: fact + real(kind=realtype), intent(out) :: factd + real(kind=realtype) :: temp + real(kind=realtype) :: temp0 + if (.not.useroughsa) then + fact = -one + factd = 0.0_8 + return + else + temp = ks(i, j, k) + d2wall(i, j, k)/0.03_realtype + temp0 = (ks(i, j, k)-d2wall(i, j, k)/0.03_realtype)/temp + factd = -((1.0/0.03_realtype+temp0/0.03_realtype)*d2walld(i, j, k)& +& /temp) + fact = temp0 + if (ks(i, j, k) .eq. 0.01 .or. d2wall(i, j, k) .eq. 0.01) print*, & +& i, j, k& +& , fact, & +& d2wall(i& +& , j, k)& +& , ks(i, & +& j, k) + end if + end subroutine saroughfact_d + + subroutine saroughfact(i, j, k, fact) +! returns either the regular sa-boundary condition +! or the modified roughness-boundary condition + use constants + use inputphysics, only : useroughsa + use blockpointers, only : ks, d2wall, il, jl, kl + implicit none +! local variablse + integer(kind=inttype), intent(in) :: i, j, k + real(kind=realtype), intent(out) :: fact + if (.not.useroughsa) then + fact = -one + return + else + fact = (ks(i, j, k)-d2wall(i, j, k)/0.03_realtype)/(ks(i, j, k)+& +& d2wall(i, j, k)/0.03_realtype) + if (ks(i, j, k) .eq. 0.01 .or. d2wall(i, j, k) .eq. 0.01) print*, & +& i, j, k& +& , fact, & +& d2wall(i& +& , j, k)& +& , ks(i, & +& j, k) + end if + end subroutine saroughfact + end module turbbcroutines_d diff --git a/src/adjoint/outputForward/turbUtils_d.f90 b/src/adjoint/outputForward/turbUtils_d.f90 index 274215a60..d2cb16708 100644 --- a/src/adjoint/outputForward/turbUtils_d.f90 +++ b/src/adjoint/outputForward/turbUtils_d.f90 @@ -884,8 +884,9 @@ subroutine turbadvection_d(madv, nadv, offset, qq) use constants use blockpointers, only : nx, ny, nz, il, jl, kl, vol, vold, & & sfacei, sfaceid, sfacej, sfacejd, sfacek, sfacekd, w, wd, si, sid, & -& sj, sjd, sk, skd, addgridvelocities, bmti1, bmti2, bmtj1, bmtj2, & -& bmtk1, bmtk2, scratch, scratchd +& sj, sjd, sk, skd, addgridvelocities, bmti1, bmti1d, bmti2, bmti2d, & +& bmtj1, bmtj1d, bmtj2, bmtj2d, bmtk1, bmtk1d, bmtk2, bmtk2d, scratch,& +& scratchd use inputdiscretization, only : orderturb use iteration, only : groundlevel use turbmod, only : secondord diff --git a/src/adjoint/outputForward/utils_d.f90 b/src/adjoint/outputForward/utils_d.f90 index ac9f6f0e4..09821228d 100644 --- a/src/adjoint/outputForward/utils_d.f90 +++ b/src/adjoint/outputForward/utils_d.f90 @@ -732,12 +732,13 @@ subroutine setbcpointers(nn, spatialpointers) use blockpointers, only : w, p, rlv, rev, gamma, x, d2wall, si, sj& & , sk, s, globalcell, bcdata, nx, il, ie, ib, ny, jl, je, jb, nz, kl,& & ke, kb, bcfaceid, addgridvelocities, sfacei, sfacej, sfacek, & -& addgridvelocities +& addgridvelocities, d2wall, ks use bcpointers_d, only : ww0, ww1, ww2, ww3, pp0, pp1, pp2, pp3, & & rlv0, rlv1, rlv2, rlv3, rev0, rev1, rev2, rev3, gamma0, gamma1, & & gamma2, gamma3, gcp, xx, ss, ssi, ssj, ssk, dd2wall, sface, istart, & -& iend, jstart, jend, isize, jsize - use inputphysics, only : cpmodel, equations +& iend, jstart, jend, isize, jsize, d2wall0, d2wall1, d2wall2, d2wall3& +& , ks0, ks1, ks2, ks3 + use inputphysics, only : cpmodel, equations, useroughsa implicit none ! subroutine arguments. integer(kind=inttype), intent(in) :: nn @@ -772,6 +773,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(2, 1:, 1:) rev1 => rev(1, 1:, 1:) rev0 => rev(0, 1:, 1:) + d2wall3 => d2wall(3, 1:, 1:) + d2wall2 => d2wall(2, 1:, 1:) + d2wall1 => d2wall(1, 1:, 1:) + d2wall0 => d2wall(0, 1:, 1:) + if (useroughsa) then + ks3 => ks(3, 1:, 1:) + ks2 => ks(2, 1:, 1:) + ks1 => ks(1, 1:, 1:) + ks0 => ks(0, 1:, 1:) + end if gamma3 => gamma(3, 1:, 1:) gamma2 => gamma(2, 1:, 1:) gamma1 => gamma(1, 1:, 1:) @@ -795,6 +806,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(il, 1:, 1:) rev1 => rev(ie, 1:, 1:) rev0 => rev(ib, 1:, 1:) + d2wall3 => d2wall(nx, 1:, 1:) + d2wall2 => d2wall(il, 1:, 1:) + d2wall1 => d2wall(ie, 1:, 1:) + d2wall0 => d2wall(ib, 1:, 1:) + if (useroughsa) then + ks3 => ks(nx, 1:, 1:) + ks2 => ks(il, 1:, 1:) + ks1 => ks(ie, 1:, 1:) + ks0 => ks(ib, 1:, 1:) + end if gamma3 => gamma(nx, 1:, 1:) gamma2 => gamma(il, 1:, 1:) gamma1 => gamma(ie, 1:, 1:) @@ -818,6 +839,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(1:, 2, 1:) rev1 => rev(1:, 1, 1:) rev0 => rev(1:, 0, 1:) + d2wall3 => d2wall(1:, 3, 1:) + d2wall2 => d2wall(1:, 2, 1:) + d2wall1 => d2wall(1:, 1, 1:) + d2wall0 => d2wall(1:, 0, 1:) + if (useroughsa) then + ks3 => ks(1:, 3, 1:) + ks2 => ks(1:, 2, 1:) + ks1 => ks(1:, 1, 1:) + ks0 => ks(1:, 0, 1:) + end if gamma3 => gamma(1:, 3, 1:) gamma2 => gamma(1:, 2, 1:) gamma1 => gamma(1:, 1, 1:) @@ -841,6 +872,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(1:, jl, 1:) rev1 => rev(1:, je, 1:) rev0 => rev(1:, jb, 1:) + d2wall3 => d2wall(1:, ny, 1:) + d2wall2 => d2wall(1:, jl, 1:) + d2wall1 => d2wall(1:, je, 1:) + d2wall0 => d2wall(1:, jb, 1:) + if (useroughsa) then + ks3 => ks(1:, ny, 1:) + ks2 => ks(1:, jl, 1:) + ks1 => ks(1:, je, 1:) + ks0 => ks(1:, jb, 1:) + end if gamma3 => gamma(1:, ny, 1:) gamma2 => gamma(1:, jl, 1:) gamma1 => gamma(1:, je, 1:) @@ -864,6 +905,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(1:, 1:, 2) rev1 => rev(1:, 1:, 1) rev0 => rev(1:, 1:, 0) + d2wall3 => d2wall(1:, 1:, 3) + d2wall2 => d2wall(1:, 1:, 2) + d2wall1 => d2wall(1:, 1:, 1) + d2wall0 => d2wall(1:, 1:, 0) + if (useroughsa) then + ks3 => ks(1:, 1:, 3) + ks2 => ks(1:, 1:, 2) + ks1 => ks(1:, 1:, 1) + ks0 => ks(1:, 1:, 0) + end if gamma3 => gamma(1:, 1:, 3) gamma2 => gamma(1:, 1:, 2) gamma1 => gamma(1:, 1:, 1) @@ -887,6 +938,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(1:, 1:, kl) rev1 => rev(1:, 1:, ke) rev0 => rev(1:, 1:, kb) + d2wall3 => d2wall(1:, 1:, nz) + d2wall2 => d2wall(1:, 1:, kl) + d2wall1 => d2wall(1:, 1:, ke) + d2wall0 => d2wall(1:, 1:, kb) + if (useroughsa) then + ks3 => ks(1:, 1:, nz) + ks2 => ks(1:, 1:, kl) + ks1 => ks(1:, 1:, ke) + ks0 => ks(1:, 1:, kb) + end if gamma3 => gamma(1:, 1:, nz) gamma2 => gamma(1:, 1:, kl) gamma1 => gamma(1:, 1:, ke) diff --git a/src/adjoint/outputReverse/BCData_b.f90 b/src/adjoint/outputReverse/BCData_b.f90 index f3684fe6a..4d7ef5267 100644 --- a/src/adjoint/outputReverse/BCData_b.f90 +++ b/src/adjoint/outputReverse/BCData_b.f90 @@ -13,11 +13,28 @@ module bcdata_b subroutine setbcvarnamesisothermalwall() use cgnsnames use constants + use inputphysics, only : useroughsa implicit none nbcvar = nbcvarisothermalwall bcvarnames(1) = cgnstemp + if (useroughsa) then + nbcvar = nbcvar + 1 + bcvarnames(2) = cgnssandgrainroughness + end if end subroutine setbcvarnamesisothermalwall + subroutine setbcvarnamesadiabaticwall() + use cgnsnames + use constants + use inputphysics, only : useroughsa + implicit none + nbcvar = nbcvaradiabaticwall + if (useroughsa) then + nbcvar = nbcvar + 1 + bcvarnames(1) = cgnssandgrainroughness + end if + end subroutine setbcvarnamesadiabaticwall + subroutine setbcvarnamessubsonicinflow() use constants use cgnsnames @@ -346,6 +363,7 @@ subroutine bcdataisothermalwall_b(boco, bcvararray, bcvararrayd, ibeg& use blockpointers, only : bcfaceid, bcdata, bcdatad, nbkglobal use utils_b, only : terminate, sitemperature use flowvarrefstate, only : tref, trefd + use inputphysics, only : useroughsa implicit none ! ! subroutine arguments. @@ -395,6 +413,7 @@ subroutine bcdataisothermalwall(boco, bcvararray, ibeg, iend, jbeg, & use blockpointers, only : bcfaceid, bcdata, nbkglobal use utils_b, only : terminate, sitemperature use flowvarrefstate, only : tref + use inputphysics, only : useroughsa implicit none ! ! subroutine arguments. @@ -420,8 +439,54 @@ subroutine bcdataisothermalwall(boco, bcvararray, ibeg, iend, jbeg, & & tref end do end do +! set a value of 0 if it was not possible to determine the +! sand grain roughness + if (useroughsa) then +! set a value of 0 if it was not possible to determine the +! sand grain roughness + if (.not.bcvarpresent(1)) bcvararray(:, :, 2) = zero + do j=jbeg,jend + do i=ibeg,iend + bcdata(boco)%ksns_wall(i, j) = bcvararray(i, j, 2) + end do + end do + end if end subroutine bcdataisothermalwall + subroutine bcdataadiabaticwall(boco, bcvararray, ibeg, iend, jbeg, & +& jend) +! +! tries to extract the equivalent sand grain roughness. it sets +! a default value of 0.0 +! + use constants + use cgnsnames + use inputphysics, only : useroughsa + use blockpointers, only : bcfaceid, bcdata, nbkglobal + implicit none +! +! subroutine arguments. +! + integer(kind=inttype) :: boco + integer(kind=inttype) :: ibeg, iend, jbeg, jend + real(kind=realtype), dimension(ibeg:iend, jbeg:jend, nbcvarmax) :: & +& bcvararray +! +! local variables. +! + integer(kind=inttype) :: i, j + if (useroughsa) then +! set a value of 0 if it was not possible to determine the +! sand grain roughness + if (.not.bcvarpresent(1)) bcvararray(:, :, 1) = zero + do j=jbeg,jend + do i=ibeg,iend + bcdata(boco)%ksns_wall(i, j) = bcvararray(i, j, 1) + end do + end do + end if + end subroutine bcdataadiabaticwall + ! differentiation of bcdatasubsonicinflow in reverse (adjoint) mode (with options noisize i4 dr8 r8): ! gradient of useful results: muref tref winf href pref rhoref ! *(*bcdata.ptinlet) *(*bcdata.ttinlet) *(*bcdata.htinlet) diff --git a/src/adjoint/outputReverse/BCRoutines_b.f90 b/src/adjoint/outputReverse/BCRoutines_b.f90 index cdbf2ebf7..e8ed35f16 100644 --- a/src/adjoint/outputReverse/BCRoutines_b.f90 +++ b/src/adjoint/outputReverse/BCRoutines_b.f90 @@ -156,15 +156,16 @@ subroutine applyallbc_block(secondhalo) end subroutine applyallbc_block ! differentiation of bcsymm1sthalo in reverse (adjoint) mode (with options noisize i4 dr8 r8): -! gradient of useful results: *rev1 *rev2 *pp1 *pp2 *rlv1 -! *rlv2 *ww1 *ww2 *(*bcdata.norm) -! with respect to varying inputs: *rev1 *rev2 *pp1 *pp2 *rlv1 -! *rlv2 *ww1 *ww2 *(*bcdata.norm) -! rw status of diff variables: *rev1:in-out *rev2:incr *pp1:in-out -! *pp2:incr *rlv1:in-out *rlv2:incr *ww1:in-out -! *ww2:incr *(*bcdata.norm):incr -! plus diff mem management of: rev1:in rev2:in pp1:in pp2:in -! rlv1:in rlv2:in ww1:in ww2:in bcdata:in *bcdata.norm:in +! gradient of useful results: *rev1 *rev2 *d2wall1 *d2wall2 +! *pp1 *pp2 *rlv1 *rlv2 *ww1 *ww2 *(*bcdata.norm) +! with respect to varying inputs: *rev1 *rev2 *d2wall1 *d2wall2 +! *pp1 *pp2 *rlv1 *rlv2 *ww1 *ww2 *(*bcdata.norm) +! rw status of diff variables: *rev1:in-out *rev2:incr *d2wall1:in-out +! *d2wall2:incr *pp1:in-out *pp2:incr *rlv1:in-out +! *rlv2:incr *ww1:in-out *ww2:incr *(*bcdata.norm):incr +! plus diff mem management of: rev1:in rev2:in d2wall1:in d2wall2:in +! pp1:in pp2:in rlv1:in rlv2:in ww1:in ww2:in bcdata:in +! *bcdata.norm:in ! =================================================================== ! actual implementation of each of the boundary condition routines ! =================================================================== @@ -180,9 +181,11 @@ subroutine bcsymm1sthalo_b(nn) use constants use blockpointers, only : bcdata, bcdatad use flowvarrefstate, only : viscous, eddymodel + use inputphysics, only : useroughsa use bcpointers_b, only : gamma1, gamma2, ww1, ww1d, ww2, ww2d, pp1, & & pp1d, pp2, pp2d, rlv1, rlv1d, rlv2, rlv2d, istart, jstart, isize, & -& jsize, rev1, rev1d, rev2, rev2d +& jsize, rev1, rev1d, rev2, rev2d, d2wall1, d2wall1d, d2wall2, & +& d2wall2d, ks1, ks2 implicit none ! subroutine arguments. integer(kind=inttype), intent(in) :: nn @@ -220,6 +223,8 @@ subroutine bcsymm1sthalo_b(nn) rlv2d(i, j) = rlv2d(i, j) + rlv1d(i, j) rlv1d(i, j) = 0.0_8 end if + d2wall2d(i, j) = d2wall2d(i, j) + d2wall1d(i, j) + d2wall1d(i, j) = 0.0_8 pp2d(i, j) = pp2d(i, j) + pp1d(i, j) pp1d(i, j) = 0.0_8 ww2d(i, j, irhoe) = ww2d(i, j, irhoe) + ww1d(i, j, irhoe) @@ -267,8 +272,10 @@ subroutine bcsymm1sthalo(nn) use constants use blockpointers, only : bcdata use flowvarrefstate, only : viscous, eddymodel + use inputphysics, only : useroughsa use bcpointers_b, only : gamma1, gamma2, ww1, ww2, pp1, pp2, rlv1, & -& rlv2, istart, jstart, isize, jsize, rev1, rev2 +& rlv2, istart, jstart, isize, jsize, rev1, rev2, d2wall1, d2wall2, & +& ks1, ks2 implicit none ! subroutine arguments. integer(kind=inttype), intent(in) :: nn @@ -298,6 +305,8 @@ subroutine bcsymm1sthalo(nn) ! laminar and eddy viscosity in the halo. gamma1(i, j) = gamma2(i, j) pp1(i, j) = pp2(i, j) + d2wall1(i, j) = d2wall2(i, j) + if (useroughsa) ks1(i, j) = ks2(i, j) if (viscous) rlv1(i, j) = rlv2(i, j) if (eddymodel) rev1(i, j) = rev2(i, j) end do @@ -305,14 +314,14 @@ end subroutine bcsymm1sthalo ! differentiation of bcsymm2ndhalo in reverse (adjoint) mode (with options noisize i4 dr8 r8): ! gradient of useful results: *rev0 *rev3 *pp0 *pp3 *rlv0 -! *rlv3 *ww0 *ww3 *(*bcdata.norm) +! *rlv3 *ww0 *ww3 ! with respect to varying inputs: *rev0 *rev3 *pp0 *pp3 *rlv0 -! *rlv3 *ww0 *ww3 *(*bcdata.norm) +! *rlv3 *ww0 *ww3 ! rw status of diff variables: *rev0:in-out *rev3:incr *pp0:in-out ! *pp3:incr *rlv0:in-out *rlv3:incr *ww0:in-out -! *ww3:incr *(*bcdata.norm):incr +! *ww3:incr ! plus diff mem management of: rev0:in rev3:in pp0:in pp3:in -! rlv0:in rlv3:in ww0:in ww3:in bcdata:in *bcdata.norm:in +! rlv0:in rlv3:in ww0:in ww3:in subroutine bcsymm2ndhalo_b(nn) ! bcsymm2ndhalo applies the symmetry boundary conditions to a ! block for the 2nd halo. this routine is separate as it makes @@ -320,9 +329,11 @@ subroutine bcsymm2ndhalo_b(nn) use constants use blockpointers, only : bcdata, bcdatad use flowvarrefstate, only : viscous, eddymodel + use inputphysics, only : useroughsa use bcpointers_b, only : gamma0, gamma3, ww0, ww0d, ww3, ww3d, pp0, & -& pp0d, pp3, pp3d, rlv0, rlv0d, rlv3, rlv3d, rev0, rev0d, rev3, rev3d,& -& istart, jstart, isize, jsize +& pp0d, pp3, pp3d, rlv0, rlv0d, rlv3, rlv3d, d2wall0, d2wall0d, & +& d2wall3, d2wall3d, ks0, ks3, rev0, rev0d, rev3, rev3d, istart, & +& jstart, isize, jsize implicit none ! subroutine arguments. integer(kind=inttype), intent(in) :: nn @@ -337,9 +348,6 @@ subroutine bcsymm2ndhalo_b(nn) do ii=0,isize*jsize-1 i = mod(ii, isize) + istart j = ii/isize + jstart - vn = two*(ww3(i, j, ivx)*bcdata(nn)%norm(i, j, 1)+ww3(i, j, ivy)*& -& bcdata(nn)%norm(i, j, 2)+ww3(i, j, ivz)*bcdata(nn)%norm(i, j, 3)& -& ) ! determine the flow variables in the halo cell. ! set the pressure and gamma and possibly the ! laminar and eddy viscosity in the halo. @@ -363,29 +371,19 @@ subroutine bcsymm2ndhalo_b(nn) ww0d(i, j, irhoe) = 0.0_8 ww3d(i, j, ivz) = ww3d(i, j, ivz) + ww0d(i, j, ivz) vnd = -(bcdata(nn)%norm(i, j, 3)*ww0d(i, j, ivz)) - bcdatad(nn)%norm(i, j, 3) = bcdatad(nn)%norm(i, j, 3) - vn*ww0d(i& -& , j, ivz) ww0d(i, j, ivz) = 0.0_8 ww3d(i, j, ivy) = ww3d(i, j, ivy) + ww0d(i, j, ivy) vnd = vnd - bcdata(nn)%norm(i, j, 2)*ww0d(i, j, ivy) - bcdatad(nn)%norm(i, j, 2) = bcdatad(nn)%norm(i, j, 2) - vn*ww0d(i& -& , j, ivy) ww0d(i, j, ivy) = 0.0_8 ww3d(i, j, ivx) = ww3d(i, j, ivx) + ww0d(i, j, ivx) vnd = vnd - bcdata(nn)%norm(i, j, 1)*ww0d(i, j, ivx) - tempd = two*vnd - bcdatad(nn)%norm(i, j, 1) = bcdatad(nn)%norm(i, j, 1) + ww3(i, j, & -& ivx)*tempd - vn*ww0d(i, j, ivx) ww0d(i, j, ivx) = 0.0_8 ww3d(i, j, irho) = ww3d(i, j, irho) + ww0d(i, j, irho) ww0d(i, j, irho) = 0.0_8 + tempd = two*vnd ww3d(i, j, ivx) = ww3d(i, j, ivx) + bcdata(nn)%norm(i, j, 1)*tempd ww3d(i, j, ivy) = ww3d(i, j, ivy) + bcdata(nn)%norm(i, j, 2)*tempd - bcdatad(nn)%norm(i, j, 2) = bcdatad(nn)%norm(i, j, 2) + ww3(i, j, & -& ivy)*tempd ww3d(i, j, ivz) = ww3d(i, j, ivz) + bcdata(nn)%norm(i, j, 3)*tempd - bcdatad(nn)%norm(i, j, 3) = bcdatad(nn)%norm(i, j, 3) + ww3(i, j, & -& ivz)*tempd end do end subroutine bcsymm2ndhalo_b @@ -396,8 +394,10 @@ subroutine bcsymm2ndhalo(nn) use constants use blockpointers, only : bcdata use flowvarrefstate, only : viscous, eddymodel + use inputphysics, only : useroughsa use bcpointers_b, only : gamma0, gamma3, ww0, ww3, pp0, pp3, rlv0, & -& rlv3, rev0, rev3, istart, jstart, isize, jsize +& rlv3, d2wall0, d2wall3, ks0, ks3, rev0, rev3, istart, jstart, isize,& +& jsize implicit none ! subroutine arguments. integer(kind=inttype), intent(in) :: nn @@ -424,21 +424,24 @@ subroutine bcsymm2ndhalo(nn) ! laminar and eddy viscosity in the halo. gamma0(i, j) = gamma3(i, j) pp0(i, j) = pp3(i, j) + d2wall0(i, j) = d2wall3(i, j) + if (useroughsa) ks0(i, j) = ks3(i, j) if (viscous) rlv0(i, j) = rlv3(i, j) if (eddymodel) rev0(i, j) = rev3(i, j) end do end subroutine bcsymm2ndhalo ! differentiation of bcsymmpolar1sthalo in reverse (adjoint) mode (with options noisize i4 dr8 r8): -! gradient of useful results: *xx *rev1 *rev2 *pp1 *pp2 *rlv1 -! *rlv2 *ww1 *ww2 -! with respect to varying inputs: *xx *rev1 *rev2 *pp1 *pp2 *rlv1 -! *rlv2 *ww1 *ww2 +! gradient of useful results: *xx *rev1 *rev2 *d2wall1 *d2wall2 +! *pp1 *pp2 *rlv1 *rlv2 *ww1 *ww2 +! with respect to varying inputs: *xx *rev1 *rev2 *d2wall1 *d2wall2 +! *pp1 *pp2 *rlv1 *rlv2 *ww1 *ww2 ! rw status of diff variables: *xx:incr *rev1:in-out *rev2:incr -! *pp1:in-out *pp2:incr *rlv1:in-out *rlv2:incr -! *ww1:in-out *ww2:incr -! plus diff mem management of: xx:in rev1:in rev2:in pp1:in pp2:in -! rlv1:in rlv2:in ww1:in ww2:in +! *d2wall1:in-out *d2wall2:incr *pp1:in-out *pp2:incr +! *rlv1:in-out *rlv2:incr *ww1:in-out *ww2:incr +! plus diff mem management of: xx:in rev1:in rev2:in d2wall1:in +! d2wall2:in pp1:in pp2:in rlv1:in rlv2:in ww1:in +! ww2:in subroutine bcsymmpolar1sthalo_b(nn) ! bcsymmpolar applies the polar symmetry boundary conditions to a ! singular line of a block. it is assumed that the pointers in @@ -447,9 +450,10 @@ subroutine bcsymmpolar1sthalo_b(nn) ! case of a degenerate line, as this line is the axi-symmetric ! centerline. this routine does just the 1st level halo. use constants + use inputphysics, only : useroughsa use bcpointers_b, only : ww1, ww1d, ww2, ww2d, pp1, pp1d, pp2, pp2d,& & rlv1, rlv1d, rlv2, rlv2d, rev1, rev1d, rev2, rev2d, xx, xxd, istart,& -& jstart, isize, jsize +& jstart, isize, jsize, d2wall1, d2wall1d, d2wall2, d2wall2d, ks1, ks2 use flowvarrefstate, only : viscous, eddymodel implicit none ! subroutine arguments. @@ -514,6 +518,8 @@ subroutine bcsymmpolar1sthalo_b(nn) rlv2d(i, j) = rlv2d(i, j) + rlv1d(i, j) rlv1d(i, j) = 0.0_8 end if + d2wall2d(i, j) = d2wall2d(i, j) + d2wall1d(i, j) + d2wall1d(i, j) = 0.0_8 pp2d(i, j) = pp2d(i, j) + pp1d(i, j) pp1d(i, j) = 0.0_8 ww2d(i, j, irhoe) = ww2d(i, j, irhoe) + ww1d(i, j, irhoe) @@ -569,8 +575,9 @@ subroutine bcsymmpolar1sthalo(nn) ! case of a degenerate line, as this line is the axi-symmetric ! centerline. this routine does just the 1st level halo. use constants + use inputphysics, only : useroughsa use bcpointers_b, only : ww1, ww2, pp1, pp2, rlv1, rlv2, rev1, rev2,& -& xx, istart, jstart, isize, jsize +& xx, istart, jstart, isize, jsize, d2wall1, d2wall2, ks1, ks2 use flowvarrefstate, only : viscous, eddymodel implicit none ! subroutine arguments. @@ -622,21 +629,24 @@ subroutine bcsymmpolar1sthalo(nn) ! set the pressure and possibly the laminar and ! eddy viscosity in the halo. pp1(i, j) = pp2(i, j) + d2wall1(i, j) = d2wall2(i, j) + if (useroughsa) ks1(i, j) = ks2(i, j) if (viscous) rlv1(i, j) = rlv2(i, j) if (eddymodel) rev1(i, j) = rev2(i, j) end do end subroutine bcsymmpolar1sthalo ! differentiation of bcsymmpolar2ndhalo in reverse (adjoint) mode (with options noisize i4 dr8 r8): -! gradient of useful results: *xx *rev0 *rev3 *pp0 *pp3 *rlv0 -! *rlv3 *ww0 *ww3 -! with respect to varying inputs: *xx *rev0 *rev3 *pp0 *pp3 *rlv0 -! *rlv3 *ww0 *ww3 -! rw status of diff variables: *xx:incr *rev0:in-out *rev3:incr -! *pp0:in-out *pp3:incr *rlv0:in-out *rlv3:incr -! *ww0:in-out *ww3:incr -! plus diff mem management of: xx:in rev0:in rev3:in pp0:in pp3:in -! rlv0:in rlv3:in ww0:in ww3:in +! gradient of useful results: *xx *rev0 *d2wall0 *rev3 *d2wall3 +! *pp0 *pp3 *rlv0 *rlv3 *ww0 *ww3 +! with respect to varying inputs: *xx *rev0 *d2wall0 *rev3 *d2wall3 +! *pp0 *pp3 *rlv0 *rlv3 *ww0 *ww3 +! rw status of diff variables: *xx:incr *rev0:in-out *d2wall0:in-out +! *rev3:incr *d2wall3:incr *pp0:in-out *pp3:incr +! *rlv0:in-out *rlv3:incr *ww0:in-out *ww3:incr +! plus diff mem management of: xx:in rev0:in d2wall0:in rev3:in +! d2wall3:in pp0:in pp3:in rlv0:in rlv3:in ww0:in +! ww3:in subroutine bcsymmpolar2ndhalo_b(nn) ! bcsymmpolar applies the polar symmetry boundary conditions to a ! singular line of a block. it is assumed that the pointers in @@ -645,9 +655,11 @@ subroutine bcsymmpolar2ndhalo_b(nn) ! case of a degenerate line, as this line is the axi-symmetric ! centerline. this routine does just the 2nd level halo. use constants + use inputphysics, only : useroughsa use bcpointers_b, only : ww0, ww0d, ww3, ww3d, pp0, pp0d, pp3, pp3d,& -& rlv0, rlv0d, rlv3, rlv3d, rev0, rev0d, rev3, rev3d, xx, xxd, istart,& -& jstart, isize, jsize +& rlv0, rlv0d, rlv3, rlv3d, rev0, rev0d, rev3, rev3d, d2wall0, & +& d2wall0d, d2wall3, d2wall3d, ks0, ks3, xx, xxd, istart, jstart, & +& isize, jsize use flowvarrefstate, only : viscous, eddymodel implicit none ! subroutine arguments. @@ -712,6 +724,8 @@ subroutine bcsymmpolar2ndhalo_b(nn) rlv3d(i, j) = rlv3d(i, j) + rlv0d(i, j) rlv0d(i, j) = 0.0_8 end if + d2wall3d(i, j) = d2wall3d(i, j) + d2wall0d(i, j) + d2wall0d(i, j) = 0.0_8 pp3d(i, j) = pp3d(i, j) + pp0d(i, j) pp0d(i, j) = 0.0_8 ww3d(i, j, irhoe) = ww3d(i, j, irhoe) + ww0d(i, j, irhoe) @@ -767,8 +781,9 @@ subroutine bcsymmpolar2ndhalo(nn) ! case of a degenerate line, as this line is the axi-symmetric ! centerline. this routine does just the 2nd level halo. use constants + use inputphysics, only : useroughsa use bcpointers_b, only : ww0, ww3, pp0, pp3, rlv0, rlv3, rev0, rev3,& -& xx, istart, jstart, isize, jsize +& d2wall0, d2wall3, ks0, ks3, xx, istart, jstart, isize, jsize use flowvarrefstate, only : viscous, eddymodel implicit none ! subroutine arguments. @@ -818,6 +833,8 @@ subroutine bcsymmpolar2ndhalo(nn) ! set the pressure and possibly the laminar and ! eddy viscosity in the halo. pp0(i, j) = pp3(i, j) + d2wall0(i, j) = d2wall3(i, j) + if (useroughsa) ks0(i, j) = ks3(i, j) if (viscous) rlv0(i, j) = rlv3(i, j) if (eddymodel) rev0(i, j) = rev3(i, j) end do diff --git a/src/adjoint/outputReverse/sa_b.f90 b/src/adjoint/outputReverse/sa_b.f90 index e960263e3..83b5c3b31 100644 --- a/src/adjoint/outputReverse/sa_b.f90 +++ b/src/adjoint/outputReverse/sa_b.f90 @@ -42,6 +42,8 @@ subroutine sasource_b() real(kind=realtype), parameter :: f23=two*third ! local variables. integer(kind=inttype) :: i, j, k, nn, ii + real(kind=realtype) :: distrough + real(kind=realtype) :: distroughd real(kind=realtype) :: fv1, fv2, ft2 real(kind=realtype) :: fv1d, fv2d, ft2d real(kind=realtype) :: ss, sst, nu, dist2inv, chi, chi2, chi3 @@ -184,12 +186,26 @@ subroutine sasource_b() ! and nu) and the functions fv1 and fv2. the latter corrects ! the production term near a viscous wall. nu = rlv(i, j, k)/w(i, j, k, irho) - dist2inv = one/d2wall(i, j, k)**2 chi = w(i, j, k, itu1)/nu + if (.not.useroughsa) then + dist2inv = one/d2wall(i, j, k)**2 + call pushcontrol1b(0) + else + distrough = d2wall(i, j, k) + 0.03_realtype*ks(i, j, k) + dist2inv = one/distrough**2 + chi = chi + rsacr1*ks(i, j, k)/distrough + call pushcontrol1b(1) + end if chi2 = chi*chi chi3 = chi*chi2 fv1 = chi3/(chi3+cv13) - fv2 = one - chi/(one+chi*fv1) + if (.not.useroughsa) then + fv2 = one - chi/(one+chi*fv1) + call pushcontrol1b(0) + else + fv2 = one - w(i, j, k, itu1)/(nu+w(i, j, k, itu1)*fv1) + call pushcontrol1b(1) + end if ! the function ft2, which is designed to keep a laminar ! solution laminar. when running in fully turbulent mode ! this function should be set to 0.0. @@ -311,18 +327,37 @@ subroutine sasource_b() else chi2d = 0.0_8 end if - tempd = -(fv2d/(one+chi*fv1)) - chid = tempd - tempd0 = -(chi*tempd/(one+chi*fv1)) - fv1d = chi*tempd0 + call popcontrol1b(branch) + if (branch .eq. 0) then + tempd = -(fv2d/(one+chi*fv1)) + tempd0 = -(chi*tempd/(one+chi*fv1)) + chid = tempd + fv1*tempd0 + fv1d = chi*tempd0 + nud = 0.0_8 + else + temp0 = w(i, j, k, itu1) + temp = nu + temp0*fv1 + tempd = w(i, j, k, itu1)*fv2d/temp**2 + wd(i, j, k, itu1) = wd(i, j, k, itu1) + fv1*tempd - fv2d/temp + nud = tempd + fv1d = temp0*tempd + chid = 0.0_8 + end if tempd = fv1d/(cv13+chi3) chi3d = (1.0-chi3/(cv13+chi3))*tempd chi2d = chi2d + chi*chi3d - chid = chid + fv1*tempd0 + chi2*chi3d + 2*chi*chi2d + chid = chid + chi2*chi3d + 2*chi*chi2d + call popcontrol1b(branch) + if (branch .eq. 0) then + temp = d2wall(i, j, k) + d2walld(i, j, k) = d2walld(i, j, k) - 2*one*dist2invd/temp**3 + else + distroughd = -(rsacr1*ks(i, j, k)*chid/distrough**2) - 2*one*& +& dist2invd/distrough**3 + d2walld(i, j, k) = d2walld(i, j, k) + distroughd + end if wd(i, j, k, itu1) = wd(i, j, k, itu1) + chid/nu - nud = -(w(i, j, k, itu1)*chid/nu**2) - temp = d2wall(i, j, k) - d2walld(i, j, k) = d2walld(i, j, k) - 2*one*dist2invd/temp**3 + nud = nud - w(i, j, k, itu1)*chid/nu**2 temp = w(i, j, k, irho) rlvd(i, j, k) = rlvd(i, j, k) + nud/temp wd(i, j, k, irho) = wd(i, j, k, irho) - rlv(i, j, k)*nud/temp**2 @@ -511,6 +546,7 @@ subroutine sasource() real(kind=realtype), parameter :: f23=two*third ! local variables. integer(kind=inttype) :: i, j, k, nn, ii + real(kind=realtype) :: distrough real(kind=realtype) :: fv1, fv2, ft2 real(kind=realtype) :: ss, sst, nu, dist2inv, chi, chi2, chi3 real(kind=realtype) :: rr, gg, gg6, termfw, fwsa, term1, term2 @@ -627,12 +663,22 @@ subroutine sasource() ! and nu) and the functions fv1 and fv2. the latter corrects ! the production term near a viscous wall. nu = rlv(i, j, k)/w(i, j, k, irho) - dist2inv = one/d2wall(i, j, k)**2 chi = w(i, j, k, itu1)/nu + if (.not.useroughsa) then + dist2inv = one/d2wall(i, j, k)**2 + else + distrough = d2wall(i, j, k) + 0.03_realtype*ks(i, j, k) + dist2inv = one/distrough**2 + chi = chi + rsacr1*ks(i, j, k)/distrough + end if chi2 = chi*chi chi3 = chi*chi2 fv1 = chi3/(chi3+cv13) - fv2 = one - chi/(one+chi*fv1) + if (.not.useroughsa) then + fv2 = one - chi/(one+chi*fv1) + else + fv2 = one - w(i, j, k, itu1)/(nu+w(i, j, k, itu1)*fv1) + end if ! the function ft2, which is designed to keep a laminar ! solution laminar. when running in fully turbulent mode ! this function should be set to 0.0. diff --git a/src/adjoint/outputReverse/turbBCRoutines_b.f90 b/src/adjoint/outputReverse/turbBCRoutines_b.f90 index 589ef941c..c16bc2266 100644 --- a/src/adjoint/outputReverse/turbBCRoutines_b.f90 +++ b/src/adjoint/outputReverse/turbBCRoutines_b.f90 @@ -6,13 +6,19 @@ module turbbcroutines_b contains ! differentiation of applyallturbbcthisblock in reverse (adjoint) mode (with options noisize i4 dr8 r8): -! gradient of useful results: *rev *w -! with respect to varying inputs: *rev *bvtj1 *bvtj2 *w *bvtk1 -! *bvtk2 *bvti1 *bvti2 -! rw status of diff variables: *rev:in-out *bvtj1:out *bvtj2:out -! *w:in-out *bvtk1:out *bvtk2:out *bvti1:out *bvti2:out +! gradient of useful results: *rev *bvtj1 *bvtj2 *w *bmtk1 +! *bmtk2 *bvtk1 *bvtk2 *d2wall *bmti1 *bmti2 *bvti1 +! *bvti2 *bmtj1 *bmtj2 +! with respect to varying inputs: *rev *bvtj1 *bvtj2 *w *bmtk1 +! *bmtk2 *bvtk1 *bvtk2 *d2wall *bmti1 *bmti2 *bvti1 +! *bvti2 *bmtj1 *bmtj2 +! rw status of diff variables: *rev:in-out *bvtj1:incr *bvtj2:incr +! *w:in-out *bmtk1:incr *bmtk2:incr *bvtk1:incr +! *bvtk2:incr *d2wall:incr *bmti1:incr *bmti2:incr +! *bvti1:incr *bvti2:incr *bmtj1:incr *bmtj2:incr ! plus diff mem management of: rev:in bvtj1:in bvtj2:in w:in -! bvtk1:in bvtk2:in bvti1:in bvti2:in +! bmtk1:in bmtk2:in bvtk1:in bvtk2:in d2wall:in +! bmti1:in bmti2:in bvti1:in bvti2:in bmtj1:in bmtj2:in ! ================================================================== subroutine applyallturbbcthisblock_b(secondhalo) ! @@ -41,6 +47,7 @@ subroutine applyallturbbcthisblock_b(secondhalo) real(kind=realtype) :: tmpd0 real(kind=realtype) :: tmp1 real(kind=realtype) :: tmpd1 + integer :: branch integer :: ad_from integer :: ad_to integer :: ad_from0 @@ -65,7 +72,6 @@ subroutine applyallturbbcthisblock_b(secondhalo) integer :: ad_to9 integer :: ad_from10 integer :: ad_to10 - integer :: branch ! loop over the boundary condition subfaces of this block. bocos:do nn=1,nbocos ! loop over the faces and set the state in @@ -78,7 +84,17 @@ subroutine applyallturbbcthisblock_b(secondhalo) ad_from0 = bcdata(nn)%jcbeg do j=ad_from0,bcdata(nn)%jcend ad_from = bcdata(nn)%icbeg - i = bcdata(nn)%icend + 1 + do i=ad_from,bcdata(nn)%icend + do l=nt1,nt2 + call pushreal8(w(1, i, j, l)) + w(1, i, j, l) = bvti1(i, j, l) + do m=nt1,nt2 + call pushreal8(w(1, i, j, l)) + w(1, i, j, l) = w(1, i, j, l) - bmti1(i, j, l, m)*w(2& +& , i, j, m) + end do + end do + end do call pushinteger4(i - 1) call pushinteger4(ad_from) end do @@ -89,7 +105,18 @@ subroutine applyallturbbcthisblock_b(secondhalo) ad_from2 = bcdata(nn)%jcbeg do j=ad_from2,bcdata(nn)%jcend ad_from1 = bcdata(nn)%icbeg - i = bcdata(nn)%icend + 1 + do i=ad_from1,bcdata(nn)%icend + do l=nt1,nt2 + call pushreal8(w(ie, i, j, l)) + w(ie, i, j, l) = bvti2(i, j, l) + do m=nt1,nt2 + tmp = w(ie, i, j, l) - bmti2(i, j, l, m)*w(il, i, j, m& +& ) + call pushreal8(w(ie, i, j, l)) + w(ie, i, j, l) = tmp + end do + end do + end do call pushinteger4(i - 1) call pushinteger4(ad_from1) end do @@ -100,7 +127,17 @@ subroutine applyallturbbcthisblock_b(secondhalo) ad_from4 = bcdata(nn)%jcbeg do j=ad_from4,bcdata(nn)%jcend ad_from3 = bcdata(nn)%icbeg - i = bcdata(nn)%icend + 1 + do i=ad_from3,bcdata(nn)%icend + do l=nt1,nt2 + call pushreal8(w(i, 1, j, l)) + w(i, 1, j, l) = bvtj1(i, j, l) + do m=nt1,nt2 + call pushreal8(w(i, 1, j, l)) + w(i, 1, j, l) = w(i, 1, j, l) - bmtj1(i, j, l, m)*w(i& +& , 2, j, m) + end do + end do + end do call pushinteger4(i - 1) call pushinteger4(ad_from3) end do @@ -111,7 +148,18 @@ subroutine applyallturbbcthisblock_b(secondhalo) ad_from6 = bcdata(nn)%jcbeg do j=ad_from6,bcdata(nn)%jcend ad_from5 = bcdata(nn)%icbeg - i = bcdata(nn)%icend + 1 + do i=ad_from5,bcdata(nn)%icend + do l=nt1,nt2 + call pushreal8(w(i, je, j, l)) + w(i, je, j, l) = bvtj2(i, j, l) + do m=nt1,nt2 + tmp0 = w(i, je, j, l) - bmtj2(i, j, l, m)*w(i, jl, j, & +& m) + call pushreal8(w(i, je, j, l)) + w(i, je, j, l) = tmp0 + end do + end do + end do call pushinteger4(i - 1) call pushinteger4(ad_from5) end do @@ -122,7 +170,17 @@ subroutine applyallturbbcthisblock_b(secondhalo) ad_from8 = bcdata(nn)%jcbeg do j=ad_from8,bcdata(nn)%jcend ad_from7 = bcdata(nn)%icbeg - i = bcdata(nn)%icend + 1 + do i=ad_from7,bcdata(nn)%icend + do l=nt1,nt2 + call pushreal8(w(i, j, 1, l)) + w(i, j, 1, l) = bvtk1(i, j, l) + do m=nt1,nt2 + call pushreal8(w(i, j, 1, l)) + w(i, j, 1, l) = w(i, j, 1, l) - bmtk1(i, j, l, m)*w(i& +& , j, 2, m) + end do + end do + end do call pushinteger4(i - 1) call pushinteger4(ad_from7) end do @@ -133,7 +191,18 @@ subroutine applyallturbbcthisblock_b(secondhalo) ad_from10 = bcdata(nn)%jcbeg do j=ad_from10,bcdata(nn)%jcend ad_from9 = bcdata(nn)%icbeg - i = bcdata(nn)%icend + 1 + do i=ad_from9,bcdata(nn)%icend + do l=nt1,nt2 + call pushreal8(w(i, j, ke, l)) + w(i, j, ke, l) = bvtk2(i, j, l) + do m=nt1,nt2 + tmp1 = w(i, j, ke, l) - bmtk2(i, j, l, m)*w(i, j, kl, & +& m) + call pushreal8(w(i, j, ke, l)) + w(i, j, ke, l) = tmp1 + end do + end do + end do call pushinteger4(i - 1) call pushinteger4(ad_from9) end do @@ -150,8 +219,21 @@ subroutine applyallturbbcthisblock_b(secondhalo) if (eddymodel) then if (bctype(nn) .eq. nswalladiabatic .or. bctype(nn) .eq. & & nswallisothermal) then +! viscous wall boundary condition. eddy viscosity is +! zero at the wall. + if (associated(rev)) then + call pushreal8array(rev, size(rev, 1)*size(rev, 2)*size(rev& +& , 3)) + call pushcontrol1b(1) + else + call pushcontrol1b(0) + end if + call bceddywall(nn) call pushcontrol2b(0) else +! any boundary condition but viscous wall. a homogeneous +! neumann condition is applied to the eddy viscosity. + call bceddynowall(nn) call pushcontrol2b(1) end if else @@ -160,22 +242,32 @@ subroutine applyallturbbcthisblock_b(secondhalo) ! extrapolate the turbulent variables in case a second halo ! is needed. if (secondhalo) then + if (associated(w)) then + call pushreal8array(w, size(w, 1)*size(w, 2)*size(w, 3)*size(w& +& , 4)) + call pushcontrol1b(1) + else + call pushcontrol1b(0) + end if + call turb2ndhalo(nn) call pushcontrol1b(1) else call pushcontrol1b(0) end if end do bocos - if (associated(bvtj1d)) bvtj1d = 0.0_8 - if (associated(bvtj2d)) bvtj2d = 0.0_8 - if (associated(bvtk1d)) bvtk1d = 0.0_8 - if (associated(bvtk2d)) bvtk2d = 0.0_8 - if (associated(bvti1d)) bvti1d = 0.0_8 - if (associated(bvti2d)) bvti2d = 0.0_8 do nn=nbocos,1,-1 call popcontrol1b(branch) - if (branch .ne. 0) call turb2ndhalo_b(nn) + if (branch .ne. 0) then + call popcontrol1b(branch) + if (branch .eq. 1) call popreal8array(w, size(w, 1)*size(w, 2)*& +& size(w, 3)*size(w, 4)) + call turb2ndhalo_b(nn) + end if call popcontrol2b(branch) if (branch .eq. 0) then + call popcontrol1b(branch) + if (branch .eq. 1) call popreal8array(rev, size(rev, 1)*size(rev& +& , 2)*size(rev, 3)) call bceddywall_b(nn) else if (branch .eq. 1) then call bceddynowall_b(nn) @@ -192,9 +284,13 @@ subroutine applyallturbbcthisblock_b(secondhalo) do i=ad_to,ad_from,-1 do l=nt2,nt1,-1 do m=nt2,nt1,-1 + call popreal8(w(1, i, j, l)) + bmti1d(i, j, l, m) = bmti1d(i, j, l, m) - w(2, i, j& +& , m)*wd(1, i, j, l) wd(2, i, j, m) = wd(2, i, j, m) - bmti1(i, j, l, m)*& & wd(1, i, j, l) end do + call popreal8(w(1, i, j, l)) bvti1d(i, j, l) = bvti1d(i, j, l) + wd(1, i, j, l) wd(1, i, j, l) = 0.0_8 end do @@ -209,11 +305,15 @@ subroutine applyallturbbcthisblock_b(secondhalo) do i=ad_to1,ad_from1,-1 do l=nt2,nt1,-1 do m=nt2,nt1,-1 + call popreal8(w(ie, i, j, l)) tmpd = wd(ie, i, j, l) wd(ie, i, j, l) = tmpd + bmti2d(i, j, l, m) = bmti2d(i, j, l, m) - w(il, i, j& +& , m)*tmpd wd(il, i, j, m) = wd(il, i, j, m) - bmti2(i, j, l, m& & )*tmpd end do + call popreal8(w(ie, i, j, l)) bvti2d(i, j, l) = bvti2d(i, j, l) + wd(ie, i, j, l) wd(ie, i, j, l) = 0.0_8 end do @@ -231,9 +331,13 @@ subroutine applyallturbbcthisblock_b(secondhalo) do i=ad_to3,ad_from3,-1 do l=nt2,nt1,-1 do m=nt2,nt1,-1 + call popreal8(w(i, 1, j, l)) + bmtj1d(i, j, l, m) = bmtj1d(i, j, l, m) - w(i, 2, j, m& +& )*wd(i, 1, j, l) wd(i, 2, j, m) = wd(i, 2, j, m) - bmtj1(i, j, l, m)*wd& & (i, 1, j, l) end do + call popreal8(w(i, 1, j, l)) bvtj1d(i, j, l) = bvtj1d(i, j, l) + wd(i, 1, j, l) wd(i, 1, j, l) = 0.0_8 end do @@ -248,11 +352,15 @@ subroutine applyallturbbcthisblock_b(secondhalo) do i=ad_to5,ad_from5,-1 do l=nt2,nt1,-1 do m=nt2,nt1,-1 + call popreal8(w(i, je, j, l)) tmpd0 = wd(i, je, j, l) wd(i, je, j, l) = tmpd0 + bmtj2d(i, j, l, m) = bmtj2d(i, j, l, m) - w(i, jl, j, & +& m)*tmpd0 wd(i, jl, j, m) = wd(i, jl, j, m) - bmtj2(i, j, l, m)*& & tmpd0 end do + call popreal8(w(i, je, j, l)) bvtj2d(i, j, l) = bvtj2d(i, j, l) + wd(i, je, j, l) wd(i, je, j, l) = 0.0_8 end do @@ -268,9 +376,13 @@ subroutine applyallturbbcthisblock_b(secondhalo) do i=ad_to7,ad_from7,-1 do l=nt2,nt1,-1 do m=nt2,nt1,-1 + call popreal8(w(i, j, 1, l)) + bmtk1d(i, j, l, m) = bmtk1d(i, j, l, m) - w(i, j, 2, m)*& +& wd(i, j, 1, l) wd(i, j, 2, m) = wd(i, j, 2, m) - bmtk1(i, j, l, m)*wd(i& & , j, 1, l) end do + call popreal8(w(i, j, 1, l)) bvtk1d(i, j, l) = bvtk1d(i, j, l) + wd(i, j, 1, l) wd(i, j, 1, l) = 0.0_8 end do @@ -285,11 +397,15 @@ subroutine applyallturbbcthisblock_b(secondhalo) do i=ad_to9,ad_from9,-1 do l=nt2,nt1,-1 do m=nt2,nt1,-1 + call popreal8(w(i, j, ke, l)) tmpd1 = wd(i, j, ke, l) wd(i, j, ke, l) = tmpd1 + bmtk2d(i, j, l, m) = bmtk2d(i, j, l, m) - w(i, j, kl, m)& +& *tmpd1 wd(i, j, kl, m) = wd(i, j, kl, m) - bmtk2(i, j, l, m)*& & tmpd1 end do + call popreal8(w(i, j, ke, l)) bvtk2d(i, j, l) = bvtk2d(i, j, l) + wd(i, j, ke, l) wd(i, j, ke, l) = 0.0_8 end do @@ -562,9 +678,9 @@ subroutine bceddynowall(nn) end subroutine bceddynowall ! differentiation of bceddywall in reverse (adjoint) mode (with options noisize i4 dr8 r8): -! gradient of useful results: *rev -! with respect to varying inputs: *rev -! plus diff mem management of: rev:in +! gradient of useful results: *rev *d2wall +! with respect to varying inputs: *rev *d2wall +! plus diff mem management of: rev:in d2wall:in subroutine bceddywall_b(nn) ! ! bceddywall sets the eddy viscosity in the halo cells of @@ -583,6 +699,8 @@ subroutine bceddywall_b(nn) ! local variables. ! integer(kind=inttype) :: i, j + real(kind=realtype) :: fact + real(kind=realtype) :: factd real(kind=realtype) :: tmp real(kind=realtype) :: tmpd real(kind=realtype) :: tmp0 @@ -594,48 +712,123 @@ subroutine bceddywall_b(nn) ! in the halo cells. select case (bcfaceid(nn)) case (imin) + do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend + do i=bcdata(nn)%icbeg,bcdata(nn)%icend + call pushreal8(fact) + call saroughfact(2, i, j, fact) + call pushreal8(rev(1, i, j)) + rev(1, i, j) = fact*rev(2, i, j) + end do + end do do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 - revd(2, i, j) = revd(2, i, j) - revd(1, i, j) + call popreal8(rev(1, i, j)) + factd = rev(2, i, j)*revd(1, i, j) + revd(2, i, j) = revd(2, i, j) + fact*revd(1, i, j) revd(1, i, j) = 0.0_8 + call popreal8(fact) + call saroughfact_b(2, i, j, fact, factd) end do end do case (imax) + do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend + do i=bcdata(nn)%icbeg,bcdata(nn)%icend + call pushreal8(fact) + call saroughfact(il, i, j, fact) + tmp = fact*rev(il, i, j) + call pushreal8(rev(ie, i, j)) + rev(ie, i, j) = tmp + end do + end do do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + call popreal8(rev(ie, i, j)) tmpd = revd(ie, i, j) revd(ie, i, j) = 0.0_8 - revd(il, i, j) = revd(il, i, j) - tmpd + factd = rev(il, i, j)*tmpd + revd(il, i, j) = revd(il, i, j) + fact*tmpd + call popreal8(fact) + call saroughfact_b(il, i, j, fact, factd) end do end do case (jmin) + do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend + do i=bcdata(nn)%icbeg,bcdata(nn)%icend + call pushreal8(fact) + call saroughfact(i, 2, j, fact) + call pushreal8(rev(i, 1, j)) + rev(i, 1, j) = fact*rev(i, 2, j) + end do + end do do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 - revd(i, 2, j) = revd(i, 2, j) - revd(i, 1, j) + call popreal8(rev(i, 1, j)) + factd = rev(i, 2, j)*revd(i, 1, j) + revd(i, 2, j) = revd(i, 2, j) + fact*revd(i, 1, j) revd(i, 1, j) = 0.0_8 + call popreal8(fact) + call saroughfact_b(i, 2, j, fact, factd) end do end do case (jmax) + do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend + do i=bcdata(nn)%icbeg,bcdata(nn)%icend + call pushreal8(fact) + call saroughfact(i, jl, j, fact) + tmp0 = fact*rev(i, jl, j) + call pushreal8(rev(i, je, j)) + rev(i, je, j) = tmp0 + end do + end do do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + call popreal8(rev(i, je, j)) tmpd0 = revd(i, je, j) revd(i, je, j) = 0.0_8 - revd(i, jl, j) = revd(i, jl, j) - tmpd0 + factd = rev(i, jl, j)*tmpd0 + revd(i, jl, j) = revd(i, jl, j) + fact*tmpd0 + call popreal8(fact) + call saroughfact_b(i, jl, j, fact, factd) end do end do case (kmin) + do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend + do i=bcdata(nn)%icbeg,bcdata(nn)%icend + call pushreal8(fact) + call saroughfact(i, j, 2, fact) + call pushreal8(rev(i, j, 1)) + rev(i, j, 1) = fact*rev(i, j, 2) + end do + end do do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 - revd(i, j, 2) = revd(i, j, 2) - revd(i, j, 1) + call popreal8(rev(i, j, 1)) + factd = rev(i, j, 2)*revd(i, j, 1) + revd(i, j, 2) = revd(i, j, 2) + fact*revd(i, j, 1) revd(i, j, 1) = 0.0_8 + call popreal8(fact) + call saroughfact_b(i, j, 2, fact, factd) end do end do case (kmax) + do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend + do i=bcdata(nn)%icbeg,bcdata(nn)%icend + call pushreal8(fact) + call saroughfact(i, j, kl, fact) + tmp1 = fact*rev(i, j, kl) + call pushreal8(rev(i, j, ke)) + rev(i, j, ke) = tmp1 + end do + end do do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + call popreal8(rev(i, j, ke)) tmpd1 = revd(i, j, ke) revd(i, j, ke) = 0.0_8 - revd(i, j, kl) = revd(i, j, kl) - tmpd1 + factd = rev(i, j, kl)*tmpd1 + revd(i, j, kl) = revd(i, j, kl) + fact*tmpd1 + call popreal8(fact) + call saroughfact_b(i, j, kl, fact, factd) end do end do end select @@ -659,6 +852,7 @@ subroutine bceddywall(nn) ! local variables. ! integer(kind=inttype) :: i, j + real(kind=realtype) :: fact ! determine the face id on which the subface is located and ! loop over the faces of the subface and set the eddy viscosity ! in the halo cells. @@ -666,49 +860,58 @@ subroutine bceddywall(nn) case (imin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(1, i, j) = -rev(2, i, j) + call saroughfact(2, i, j, fact) + rev(1, i, j) = fact*rev(2, i, j) end do end do case (imax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(ie, i, j) = -rev(il, i, j) + call saroughfact(il, i, j, fact) + rev(ie, i, j) = fact*rev(il, i, j) end do end do case (jmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(i, 1, j) = -rev(i, 2, j) + call saroughfact(i, 2, j, fact) + rev(i, 1, j) = fact*rev(i, 2, j) end do end do case (jmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(i, je, j) = -rev(i, jl, j) + call saroughfact(i, jl, j, fact) + rev(i, je, j) = fact*rev(i, jl, j) end do end do case (kmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(i, j, 1) = -rev(i, j, 2) + call saroughfact(i, j, 2, fact) + rev(i, j, 1) = fact*rev(i, j, 2) end do end do case (kmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(i, j, ke) = -rev(i, j, kl) + call saroughfact(i, j, kl, fact) + rev(i, j, ke) = fact*rev(i, j, kl) end do end do end select end subroutine bceddywall ! differentiation of bcturbfarfield in reverse (adjoint) mode (with options noisize i4 dr8 r8): -! gradient of useful results: winf *bvtj1 *bvtj2 *bvtk1 *bvtk2 -! *bvti1 *bvti2 -! with respect to varying inputs: winf *bvtj1 *bvtj2 *bvtk1 *bvtk2 -! *bvti1 *bvti2 -! plus diff mem management of: bvtj1:in bvtj2:in bvtk1:in bvtk2:in -! bvti1:in bvti2:in +! gradient of useful results: winf *bvtj1 *bvtj2 *bmtk1 *bmtk2 +! *bvtk1 *bvtk2 *bmti1 *bmti2 *bvti1 *bvti2 *bmtj1 +! *bmtj2 +! with respect to varying inputs: winf *bvtj1 *bvtj2 *bmtk1 *bmtk2 +! *bvtk1 *bvtk2 *bmti1 *bmti2 *bvti1 *bvti2 *bmtj1 +! *bmtj2 +! plus diff mem management of: bvtj1:in bvtj2:in bmtk1:in bmtk2:in +! bvtk1:in bvtk2:in bmti1:in bmti2:in bvti1:in bvti2:in +! bmtj1:in bmtj2:in subroutine bcturbfarfield_b(nn) ! ! bcturbfarfield applies the implicit treatment of the @@ -745,6 +948,26 @@ subroutine bcturbfarfield_b(nn) ! determine whether we are dealing with an inflow or ! outflow boundary here. if (dot .gt. zero) then +! outflow. simply extrapolation or zero neumann bc +! of the turbulent variables. + do l=nt1,nt2 + select case (bcfaceid(nn)) + case (imin) + call pushcontrol3b(5) + case (imax) + call pushcontrol3b(4) + case (jmin) + call pushcontrol3b(3) + case (jmax) + call pushcontrol3b(2) + case (kmin) + call pushcontrol3b(1) + case (kmax) + call pushcontrol3b(0) + case default + call pushcontrol3b(6) + end select + end do call pushcontrol1b(1) else ! inflow. turbulent variables are prescribed. @@ -800,6 +1023,27 @@ subroutine bcturbfarfield_b(nn) bvti1d(i, j, l) = 0.0_8 end if end do + else + do l=nt2,nt1,-1 + call popcontrol3b(branch) + if (branch .lt. 3) then + if (branch .eq. 0) then + bmtk2d(i, j, l, l) = 0.0_8 + else if (branch .eq. 1) then + bmtk1d(i, j, l, l) = 0.0_8 + else + bmtj2d(i, j, l, l) = 0.0_8 + end if + else if (branch .lt. 5) then + if (branch .eq. 3) then + bmtj1d(i, j, l, l) = 0.0_8 + else + bmti2d(i, j, l, l) = 0.0_8 + end if + else if (branch .eq. 5) then + bmti1d(i, j, l, l) = 0.0_8 + end if + end do end if end do end do @@ -1111,6 +1355,86 @@ subroutine bcturboutflow(nn) end do end subroutine bcturboutflow +! differentiation of bcturbsymm in reverse (adjoint) mode (with options noisize i4 dr8 r8): +! gradient of useful results: *bmtk1 *bmtk2 *bmti1 *bmti2 +! *bmtj1 *bmtj2 +! with respect to varying inputs: *bmtk1 *bmtk2 *bmti1 *bmti2 +! *bmtj1 *bmtj2 +! plus diff mem management of: bmtk1:in bmtk2:in bmti1:in bmti2:in +! bmtj1:in bmtj2:in + subroutine bcturbsymm_b(nn) +! +! bcturbsymm applies the implicit treatment of the symmetry +! boundary condition (or inviscid wall) to subface nn. as the +! symmetry boundary condition is independent of the turbulence +! model, this routine is valid for all models. it is assumed +! that the pointers in blockpointers are already set to the +! correct block on the correct grid level. +! + use constants + use blockpointers + use flowvarrefstate + implicit none +! +! subroutine arguments. +! + integer(kind=inttype), intent(in) :: nn +! +! local variables. +! + integer(kind=inttype) :: i, j, l + integer :: branch +! loop over the faces of the subfaces and set the values of bmt +! for an implicit treatment. for a symmetry face this means +! that the halo value is set to the internal value. + do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend + do i=bcdata(nn)%icbeg,bcdata(nn)%icend + do l=nt1,nt2 + select case (bcfaceid(nn)) + case (imin) + call pushcontrol3b(5) + case (imax) + call pushcontrol3b(4) + case (jmin) + call pushcontrol3b(3) + case (jmax) + call pushcontrol3b(2) + case (kmin) + call pushcontrol3b(1) + case (kmax) + call pushcontrol3b(0) + case default + call pushcontrol3b(6) + end select + end do + end do + end do + do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 + do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + do l=nt2,nt1,-1 + call popcontrol3b(branch) + if (branch .lt. 3) then + if (branch .eq. 0) then + bmtk2d(i, j, l, l) = 0.0_8 + else if (branch .eq. 1) then + bmtk1d(i, j, l, l) = 0.0_8 + else + bmtj2d(i, j, l, l) = 0.0_8 + end if + else if (branch .lt. 5) then + if (branch .eq. 3) then + bmtj1d(i, j, l, l) = 0.0_8 + else + bmti2d(i, j, l, l) = 0.0_8 + end if + else if (branch .eq. 5) then + bmti1d(i, j, l, l) = 0.0_8 + end if + end do + end do + end do + end subroutine bcturbsymm_b + subroutine bcturbsymm(nn) ! ! bcturbsymm applies the implicit treatment of the symmetry @@ -1158,15 +1482,20 @@ subroutine bcturbsymm(nn) end subroutine bcturbsymm ! differentiation of bcturbtreatment in reverse (adjoint) mode (with options noisize i4 dr8 r8): -! gradient of useful results: winf *bvtj1 *bvtj2 *w *rlv -! *bvtk1 *bvtk2 *d2wall *bvti1 *bvti2 -! with respect to varying inputs: winf *bvtj1 *bvtj2 *w *rlv -! *bvtk1 *bvtk2 *d2wall *bvti1 *bvti2 +! gradient of useful results: winf *bvtj1 *bvtj2 *w *bmtk1 +! *rlv *bmtk2 *bvtk1 *bvtk2 *d2wall *bmti1 *bmti2 +! *bvti1 *bvti2 *bmtj1 *bmtj2 +! with respect to varying inputs: winf *bvtj1 *bvtj2 *w *bmtk1 +! *rlv *bmtk2 *bvtk1 *bvtk2 *d2wall *bmti1 *bmti2 +! *bvti1 *bvti2 *bmtj1 *bmtj2 ! rw status of diff variables: winf:incr *bvtj1:in-out *bvtj2:in-out -! *w:incr *rlv:incr *bvtk1:in-out *bvtk2:in-out -! *d2wall:incr *bvti1:in-out *bvti2:in-out -! plus diff mem management of: bvtj1:in bvtj2:in w:in rlv:in -! bvtk1:in bvtk2:in d2wall:in bvti1:in bvti2:in +! *w:incr *bmtk1:in-out *rlv:incr *bmtk2:in-out +! *bvtk1:in-out *bvtk2:in-out *d2wall:incr *bmti1:in-out +! *bmti2:in-out *bvti1:in-out *bvti2:in-out *bmtj1:in-out +! *bmtj2:in-out +! plus diff mem management of: bvtj1:in bvtj2:in w:in bmtk1:in +! rlv:in bmtk2:in bvtk1:in bvtk2:in d2wall:in bmti1:in +! bmti2:in bvti1:in bvti2:in bmtj1:in bmtj2:in subroutine bcturbtreatment_b() ! ! bcturbtreatment sets the arrays bmti1, bvti1, etc, such that @@ -1194,21 +1523,21 @@ subroutine bcturbtreatment_b() ! determine the kind of boundary condition for this subface. select case (bctype(nn)) case (nswalladiabatic, nswallisothermal) - call pushcontrol2b(2) + call pushcontrol3b(3) case (symm, symmpolar, eulerwall) - call pushcontrol2b(3) + call pushcontrol3b(2) case (farfield) - call pushcontrol2b(1) + call pushcontrol3b(1) case (slidinginterface, oversetouterbound, domaininterfaceall, & & domaininterfacerhouvw, domaininterfacep, domaininterfacerho, & & domaininterfacetotal) - call pushcontrol2b(0) + call pushcontrol3b(0) case default - call pushcontrol2b(3) + call pushcontrol3b(4) end select end do bocos do nn=nbocos,1,-1 - call popcontrol2b(branch) + call popcontrol3b(branch) if (branch .lt. 2) then if (branch .eq. 0) then call bcturbinterface_b(nn) @@ -1216,6 +1545,8 @@ subroutine bcturbtreatment_b() call bcturbfarfield_b(nn) end if else if (branch .eq. 2) then + call bcturbsymm_b(nn) + else if (branch .eq. 3) then call bcturbwall_b(nn) end if end do @@ -1224,6 +1555,10 @@ subroutine bcturbtreatment_b() do l=nt2,nt1,-1 bvtk2d(i, j, l) = 0.0_8 bvtk1d(i, j, l) = 0.0_8 + do m=nt2,nt1,-1 + bmtk2d(i, j, l, m) = 0.0_8 + bmtk1d(i, j, l, m) = 0.0_8 + end do end do end do end do @@ -1232,6 +1567,10 @@ subroutine bcturbtreatment_b() do l=nt2,nt1,-1 bvtj2d(i, k, l) = 0.0_8 bvtj1d(i, k, l) = 0.0_8 + do m=nt2,nt1,-1 + bmtj2d(i, k, l, m) = 0.0_8 + bmtj1d(i, k, l, m) = 0.0_8 + end do end do end do end do @@ -1240,6 +1579,10 @@ subroutine bcturbtreatment_b() do l=nt2,nt1,-1 bvti2d(j, k, l) = 0.0_8 bvti1d(j, k, l) = 0.0_8 + do m=nt2,nt1,-1 + bmti2d(j, k, l, m) = 0.0_8 + bmti1d(j, k, l, m) = 0.0_8 + end do end do end do end do @@ -1338,12 +1681,15 @@ subroutine bcturbtreatment() end subroutine bcturbtreatment ! differentiation of bcturbwall in reverse (adjoint) mode (with options noisize i4 dr8 r8): -! gradient of useful results: *bvtj1 *bvtj2 *w *rlv *bvtk1 -! *bvtk2 *d2wall *bvti1 *bvti2 -! with respect to varying inputs: *bvtj1 *bvtj2 *w *rlv *bvtk1 -! *bvtk2 *d2wall *bvti1 *bvti2 -! plus diff mem management of: bvtj1:in bvtj2:in w:in rlv:in -! bvtk1:in bvtk2:in d2wall:in bvti1:in bvti2:in +! gradient of useful results: *bvtj1 *bvtj2 *w *bmtk1 *rlv +! *bmtk2 *bvtk1 *bvtk2 *d2wall *bmti1 *bmti2 *bvti1 +! *bvti2 *bmtj1 *bmtj2 +! with respect to varying inputs: *bvtj1 *bvtj2 *w *bmtk1 *rlv +! *bmtk2 *bvtk1 *bvtk2 *d2wall *bmti1 *bmti2 *bvti1 +! *bvti2 *bmtj1 *bmtj2 +! plus diff mem management of: bvtj1:in bvtj2:in w:in bmtk1:in +! rlv:in bmtk2:in bvtk1:in bvtk2:in d2wall:in bmti1:in +! bmti2:in bvti1:in bvti2:in bmtj1:in bmtj2:in subroutine bcturbwall_b(nn) ! ! bcturbwall applies the implicit treatment of the viscous @@ -1366,8 +1712,8 @@ subroutine bcturbwall_b(nn) ! local variables. ! integer(kind=inttype) :: i, j, ii, jj, iimax, jjmax - real(kind=realtype) :: tmpd, tmpe, tmpf, nu - real(kind=realtype) :: tmpdd, nud + real(kind=realtype) :: tmpd, tmpe, tmpf, nu, fact + real(kind=realtype) :: tmpdd, nud, factd real(kind=realtype), dimension(:, :, :, :), pointer :: bmt real(kind=realtype), dimension(:, :, :), pointer :: bvt, ww2 real(kind=realtype), dimension(:, :), pointer :: rlv2, dd2wall @@ -1393,7 +1739,59 @@ subroutine bcturbwall_b(nn) ! implicit treatment. select case (turbmodel) case (spalartallmaras, spalartallmarasedwards) - +! spalart-allmaras type of model. value at the wall is zero, +! so simply negate the internal value. + select case (bcfaceid(nn)) + case (imin) + do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 + do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + factd = -bmti1d(i, j, itu1, itu1) + bmti1d(i, j, itu1, itu1) = 0.0_8 + call saroughfact_b(2, i, j, fact, factd) + end do + end do + case (imax) + do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 + do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + factd = -bmti2d(i, j, itu1, itu1) + bmti2d(i, j, itu1, itu1) = 0.0_8 + call saroughfact_b(il, i, j, fact, factd) + end do + end do + case (jmin) + do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 + do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + factd = -bmtj1d(i, j, itu1, itu1) + bmtj1d(i, j, itu1, itu1) = 0.0_8 + call saroughfact_b(i, 2, j, fact, factd) + end do + end do + case (jmax) + do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 + do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + factd = -bmtj2d(i, j, itu1, itu1) + bmtj2d(i, j, itu1, itu1) = 0.0_8 + call saroughfact_b(i, jl, j, fact, factd) + end do + end do + case (kmin) + do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 + do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + factd = -bmtk1d(i, j, itu1, itu1) + bmtk1d(i, j, itu1, itu1) = 0.0_8 + call saroughfact_b(i, j, 2, fact, factd) + end do + end do + case (kmax) + do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 + do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + factd = -bmtk2d(i, j, itu1, itu1) + bmtk2d(i, j, itu1, itu1) = 0.0_8 + call saroughfact_b(i, j, kl, fact, factd) + end do + end do + end select +! ================================================================ case (komegawilcox, komegamodified, mentersst) ! k-omega type of models. k is zero on the wall and thus the ! halo value is the negative of the first internal cell. @@ -1449,6 +1847,8 @@ subroutine bcturbwall_b(nn) bvti1d(i, j, itu2) = 0.0_8 nud = tmpd*tempd tmpdd = nu*tempd + bmti1d(i, j, itu2, itu2) = 0.0_8 + bmti1d(i, j, itu1, itu1) = 0.0_8 temp = rkwbeta1*(d2wall(2, ii, jj)*d2wall(2, ii, jj)) d2walld(2, ii, jj) = d2walld(2, ii, jj) - 2*d2wall(2, ii, jj& & )*rkwbeta1*one*tmpdd/temp**2 @@ -1513,6 +1913,8 @@ subroutine bcturbwall_b(nn) bvti2d(i, j, itu2) = 0.0_8 nud = tmpd*tempd tmpdd = nu*tempd + bmti2d(i, j, itu2, itu2) = 0.0_8 + bmti2d(i, j, itu1, itu1) = 0.0_8 temp = rkwbeta1*(d2wall(il, ii, jj)*d2wall(il, ii, jj)) d2walld(il, ii, jj) = d2walld(il, ii, jj) - 2*d2wall(il, ii& & , jj)*rkwbeta1*one*tmpdd/temp**2 @@ -1577,6 +1979,8 @@ subroutine bcturbwall_b(nn) bvtj1d(i, j, itu2) = 0.0_8 nud = tmpd*tempd tmpdd = nu*tempd + bmtj1d(i, j, itu2, itu2) = 0.0_8 + bmtj1d(i, j, itu1, itu1) = 0.0_8 temp = rkwbeta1*(d2wall(ii, 2, jj)*d2wall(ii, 2, jj)) d2walld(ii, 2, jj) = d2walld(ii, 2, jj) - 2*d2wall(ii, 2, jj& & )*rkwbeta1*one*tmpdd/temp**2 @@ -1641,6 +2045,8 @@ subroutine bcturbwall_b(nn) bvtj2d(i, j, itu2) = 0.0_8 nud = tmpd*tempd tmpdd = nu*tempd + bmtj2d(i, j, itu2, itu2) = 0.0_8 + bmtj2d(i, j, itu1, itu1) = 0.0_8 temp = rkwbeta1*(d2wall(ii, jl, jj)*d2wall(ii, jl, jj)) d2walld(ii, jl, jj) = d2walld(ii, jl, jj) - 2*d2wall(ii, jl& & , jj)*rkwbeta1*one*tmpdd/temp**2 @@ -1705,6 +2111,8 @@ subroutine bcturbwall_b(nn) bvtk1d(i, j, itu2) = 0.0_8 nud = tmpd*tempd tmpdd = nu*tempd + bmtk1d(i, j, itu2, itu2) = 0.0_8 + bmtk1d(i, j, itu1, itu1) = 0.0_8 temp = rkwbeta1*(d2wall(ii, jj, 2)*d2wall(ii, jj, 2)) d2walld(ii, jj, 2) = d2walld(ii, jj, 2) - 2*d2wall(ii, jj, 2& & )*rkwbeta1*one*tmpdd/temp**2 @@ -1769,6 +2177,8 @@ subroutine bcturbwall_b(nn) bvtk2d(i, j, itu2) = 0.0_8 nud = tmpd*tempd tmpdd = nu*tempd + bmtk2d(i, j, itu2, itu2) = 0.0_8 + bmtk2d(i, j, itu1, itu1) = 0.0_8 temp = rkwbeta1*(d2wall(ii, jj, kl)*d2wall(ii, jj, kl)) d2walld(ii, jj, kl) = d2walld(ii, jj, kl) - 2*d2wall(ii, jj& & , kl)*rkwbeta1*one*tmpdd/temp**2 @@ -1791,6 +2201,54 @@ subroutine bcturbwall_b(nn) end if end do end select +! ================================================================ + case (ktau) +! k-tau model. both k and tau are zero at the wall, so the +! negative value of the internal cell is taken for the halo. + select case (bcfaceid(nn)) + case (imin) + do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 + do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + bmti1d(i, j, itu2, itu2) = 0.0_8 + bmti1d(i, j, itu1, itu1) = 0.0_8 + end do + end do + case (imax) + do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 + do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + bmti2d(i, j, itu2, itu2) = 0.0_8 + bmti2d(i, j, itu1, itu1) = 0.0_8 + end do + end do + case (jmin) + do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 + do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + bmtj1d(i, j, itu2, itu2) = 0.0_8 + bmtj1d(i, j, itu1, itu1) = 0.0_8 + end do + end do + case (jmax) + do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 + do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + bmtj2d(i, j, itu2, itu2) = 0.0_8 + bmtj2d(i, j, itu1, itu1) = 0.0_8 + end do + end do + case (kmin) + do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 + do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + bmtk1d(i, j, itu2, itu2) = 0.0_8 + bmtk1d(i, j, itu1, itu1) = 0.0_8 + end do + end do + case (kmax) + do j=bcdata(nn)%jcend,bcdata(nn)%jcbeg,-1 + do i=bcdata(nn)%icend,bcdata(nn)%icbeg,-1 + bmtk2d(i, j, itu2, itu2) = 0.0_8 + bmtk2d(i, j, itu1, itu1) = 0.0_8 + end do + end do + end select ! ================================================================ end select end subroutine bcturbwall_b @@ -1817,7 +2275,7 @@ subroutine bcturbwall(nn) ! local variables. ! integer(kind=inttype) :: i, j, ii, jj, iimax, jjmax - real(kind=realtype) :: tmpd, tmpe, tmpf, nu + real(kind=realtype) :: tmpd, tmpe, tmpf, nu, fact real(kind=realtype), dimension(:, :, :, :), pointer :: bmt real(kind=realtype), dimension(:, :, :), pointer :: bvt, ww2 real(kind=realtype), dimension(:, :), pointer :: rlv2, dd2wall @@ -1846,37 +2304,43 @@ subroutine bcturbwall(nn) case (imin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmti1(i, j, itu1, itu1) = one + call saroughfact(2, i, j, fact) + bmti1(i, j, itu1, itu1) = -fact end do end do case (imax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmti2(i, j, itu1, itu1) = one + call saroughfact(il, i, j, fact) + bmti2(i, j, itu1, itu1) = -fact end do end do case (jmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtj1(i, j, itu1, itu1) = one + call saroughfact(i, 2, j, fact) + bmtj1(i, j, itu1, itu1) = -fact end do end do case (jmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtj2(i, j, itu1, itu1) = one + call saroughfact(i, jl, j, fact) + bmtj2(i, j, itu1, itu1) = -fact end do end do case (kmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtk1(i, j, itu1, itu1) = one + call saroughfact(i, j, 2, fact) + bmtk1(i, j, itu1, itu1) = -fact end do end do case (kmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtk2(i, j, itu1, itu1) = one + call saroughfact(i, j, kl, fact) + bmtk2(i, j, itu1, itu1) = -fact end do end do end select @@ -2547,5 +3011,55 @@ subroutine turbbcnswall(secondhalo) end do bocos end subroutine turbbcnswall +! differentiation of saroughfact in reverse (adjoint) mode (with options noisize i4 dr8 r8): +! gradient of useful results: *d2wall fact +! with respect to varying inputs: *d2wall +! plus diff mem management of: d2wall:in + subroutine saroughfact_b(i, j, k, fact, factd) +! returns either the regular sa-boundary condition +! or the modified roughness-boundary condition + use constants + use inputphysics, only : useroughsa + use blockpointers, only : ks, d2wall, d2walld, il, jl, kl + implicit none +! local variablse + integer(kind=inttype), intent(in) :: i, j, k + real(kind=realtype) :: fact + real(kind=realtype) :: factd + real(kind=realtype) :: temp + if (useroughsa) then + temp = ks(i, j, k) + d2wall(i, j, k)/0.03_realtype + d2walld(i, j, k) = d2walld(i, j, k) - (1.0/(0.03_realtype*temp)+(& +& ks(i, j, k)-d2wall(i, j, k)/0.03_realtype)/(0.03_realtype*temp**& +& 2))*factd + end if + end subroutine saroughfact_b + + subroutine saroughfact(i, j, k, fact) +! returns either the regular sa-boundary condition +! or the modified roughness-boundary condition + use constants + use inputphysics, only : useroughsa + use blockpointers, only : ks, d2wall, il, jl, kl + implicit none +! local variablse + integer(kind=inttype), intent(in) :: i, j, k + real(kind=realtype), intent(out) :: fact + if (.not.useroughsa) then + fact = -one + return + else + fact = (ks(i, j, k)-d2wall(i, j, k)/0.03_realtype)/(ks(i, j, k)+& +& d2wall(i, j, k)/0.03_realtype) + if (ks(i, j, k) .eq. 0.01 .or. d2wall(i, j, k) .eq. 0.01) print*, & +& i, j, k& +& , fact, & +& d2wall(i& +& , j, k)& +& , ks(i, & +& j, k) + end if + end subroutine saroughfact + end module turbbcroutines_b diff --git a/src/adjoint/outputReverse/turbUtils_b.f90 b/src/adjoint/outputReverse/turbUtils_b.f90 index 50ebc309c..d42719519 100644 --- a/src/adjoint/outputReverse/turbUtils_b.f90 +++ b/src/adjoint/outputReverse/turbUtils_b.f90 @@ -906,8 +906,9 @@ subroutine turbadvection_b(madv, nadv, offset, qq) use constants use blockpointers, only : nx, ny, nz, il, jl, kl, vol, vold, & & sfacei, sfaceid, sfacej, sfacejd, sfacek, sfacekd, w, wd, si, sid, & -& sj, sjd, sk, skd, addgridvelocities, bmti1, bmti2, bmtj1, bmtj2, & -& bmtk1, bmtk2, scratch, scratchd +& sj, sjd, sk, skd, addgridvelocities, bmti1, bmti1d, bmti2, bmti2d, & +& bmtj1, bmtj1d, bmtj2, bmtj2d, bmtk1, bmtk1d, bmtk2, bmtk2d, scratch,& +& scratchd use inputdiscretization, only : orderturb use iteration, only : groundlevel use turbmod, only : secondord diff --git a/src/adjoint/outputReverse/utils_b.f90 b/src/adjoint/outputReverse/utils_b.f90 index 3ad24e4bb..9d3f1d1f8 100644 --- a/src/adjoint/outputReverse/utils_b.f90 +++ b/src/adjoint/outputReverse/utils_b.f90 @@ -725,12 +725,13 @@ subroutine setbcpointers(nn, spatialpointers) use blockpointers, only : w, p, rlv, rev, gamma, x, d2wall, si, sj& & , sk, s, globalcell, bcdata, nx, il, ie, ib, ny, jl, je, jb, nz, kl,& & ke, kb, bcfaceid, addgridvelocities, sfacei, sfacej, sfacek, & -& addgridvelocities +& addgridvelocities, d2wall, ks use bcpointers_b, only : ww0, ww1, ww2, ww3, pp0, pp1, pp2, pp3, & & rlv0, rlv1, rlv2, rlv3, rev0, rev1, rev2, rev3, gamma0, gamma1, & & gamma2, gamma3, gcp, xx, ss, ssi, ssj, ssk, dd2wall, sface, istart, & -& iend, jstart, jend, isize, jsize - use inputphysics, only : cpmodel, equations +& iend, jstart, jend, isize, jsize, d2wall0, d2wall1, d2wall2, d2wall3& +& , ks0, ks1, ks2, ks3 + use inputphysics, only : cpmodel, equations, useroughsa implicit none ! subroutine arguments. integer(kind=inttype), intent(in) :: nn @@ -765,6 +766,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(2, 1:, 1:) rev1 => rev(1, 1:, 1:) rev0 => rev(0, 1:, 1:) + d2wall3 => d2wall(3, 1:, 1:) + d2wall2 => d2wall(2, 1:, 1:) + d2wall1 => d2wall(1, 1:, 1:) + d2wall0 => d2wall(0, 1:, 1:) + if (useroughsa) then + ks3 => ks(3, 1:, 1:) + ks2 => ks(2, 1:, 1:) + ks1 => ks(1, 1:, 1:) + ks0 => ks(0, 1:, 1:) + end if gamma3 => gamma(3, 1:, 1:) gamma2 => gamma(2, 1:, 1:) gamma1 => gamma(1, 1:, 1:) @@ -788,6 +799,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(il, 1:, 1:) rev1 => rev(ie, 1:, 1:) rev0 => rev(ib, 1:, 1:) + d2wall3 => d2wall(nx, 1:, 1:) + d2wall2 => d2wall(il, 1:, 1:) + d2wall1 => d2wall(ie, 1:, 1:) + d2wall0 => d2wall(ib, 1:, 1:) + if (useroughsa) then + ks3 => ks(nx, 1:, 1:) + ks2 => ks(il, 1:, 1:) + ks1 => ks(ie, 1:, 1:) + ks0 => ks(ib, 1:, 1:) + end if gamma3 => gamma(nx, 1:, 1:) gamma2 => gamma(il, 1:, 1:) gamma1 => gamma(ie, 1:, 1:) @@ -811,6 +832,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(1:, 2, 1:) rev1 => rev(1:, 1, 1:) rev0 => rev(1:, 0, 1:) + d2wall3 => d2wall(1:, 3, 1:) + d2wall2 => d2wall(1:, 2, 1:) + d2wall1 => d2wall(1:, 1, 1:) + d2wall0 => d2wall(1:, 0, 1:) + if (useroughsa) then + ks3 => ks(1:, 3, 1:) + ks2 => ks(1:, 2, 1:) + ks1 => ks(1:, 1, 1:) + ks0 => ks(1:, 0, 1:) + end if gamma3 => gamma(1:, 3, 1:) gamma2 => gamma(1:, 2, 1:) gamma1 => gamma(1:, 1, 1:) @@ -834,6 +865,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(1:, jl, 1:) rev1 => rev(1:, je, 1:) rev0 => rev(1:, jb, 1:) + d2wall3 => d2wall(1:, ny, 1:) + d2wall2 => d2wall(1:, jl, 1:) + d2wall1 => d2wall(1:, je, 1:) + d2wall0 => d2wall(1:, jb, 1:) + if (useroughsa) then + ks3 => ks(1:, ny, 1:) + ks2 => ks(1:, jl, 1:) + ks1 => ks(1:, je, 1:) + ks0 => ks(1:, jb, 1:) + end if gamma3 => gamma(1:, ny, 1:) gamma2 => gamma(1:, jl, 1:) gamma1 => gamma(1:, je, 1:) @@ -857,6 +898,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(1:, 1:, 2) rev1 => rev(1:, 1:, 1) rev0 => rev(1:, 1:, 0) + d2wall3 => d2wall(1:, 1:, 3) + d2wall2 => d2wall(1:, 1:, 2) + d2wall1 => d2wall(1:, 1:, 1) + d2wall0 => d2wall(1:, 1:, 0) + if (useroughsa) then + ks3 => ks(1:, 1:, 3) + ks2 => ks(1:, 1:, 2) + ks1 => ks(1:, 1:, 1) + ks0 => ks(1:, 1:, 0) + end if gamma3 => gamma(1:, 1:, 3) gamma2 => gamma(1:, 1:, 2) gamma1 => gamma(1:, 1:, 1) @@ -880,6 +931,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(1:, 1:, kl) rev1 => rev(1:, 1:, ke) rev0 => rev(1:, 1:, kb) + d2wall3 => d2wall(1:, 1:, nz) + d2wall2 => d2wall(1:, 1:, kl) + d2wall1 => d2wall(1:, 1:, ke) + d2wall0 => d2wall(1:, 1:, kb) + if (useroughsa) then + ks3 => ks(1:, 1:, nz) + ks2 => ks(1:, 1:, kl) + ks1 => ks(1:, 1:, ke) + ks0 => ks(1:, 1:, kb) + end if gamma3 => gamma(1:, 1:, nz) gamma2 => gamma(1:, 1:, kl) gamma1 => gamma(1:, 1:, ke) diff --git a/src/adjoint/outputReverseFast/BCRoutines_fast_b.f90 b/src/adjoint/outputReverseFast/BCRoutines_fast_b.f90 index 37f0e540f..cd24ca801 100644 --- a/src/adjoint/outputReverseFast/BCRoutines_fast_b.f90 +++ b/src/adjoint/outputReverseFast/BCRoutines_fast_b.f90 @@ -170,8 +170,10 @@ subroutine bcsymm1sthalo(nn) use constants use blockpointers, only : bcdata use flowvarrefstate, only : viscous, eddymodel + use inputphysics, only : useroughsa use bcpointers, only : gamma1, gamma2, ww1, ww2, pp1, pp2, rlv1, & -& rlv2, istart, jstart, isize, jsize, rev1, rev2 +& rlv2, istart, jstart, isize, jsize, rev1, rev2, d2wall1, d2wall2, & +& ks1, ks2 implicit none ! subroutine arguments. integer(kind=inttype), intent(in) :: nn @@ -201,6 +203,8 @@ subroutine bcsymm1sthalo(nn) ! laminar and eddy viscosity in the halo. gamma1(i, j) = gamma2(i, j) pp1(i, j) = pp2(i, j) + d2wall1(i, j) = d2wall2(i, j) + if (useroughsa) ks1(i, j) = ks2(i, j) if (viscous) rlv1(i, j) = rlv2(i, j) if (eddymodel) rev1(i, j) = rev2(i, j) end do @@ -213,8 +217,10 @@ subroutine bcsymm2ndhalo(nn) use constants use blockpointers, only : bcdata use flowvarrefstate, only : viscous, eddymodel + use inputphysics, only : useroughsa use bcpointers, only : gamma0, gamma3, ww0, ww3, pp0, pp3, rlv0, & -& rlv3, rev0, rev3, istart, jstart, isize, jsize +& rlv3, d2wall0, d2wall3, ks0, ks3, rev0, rev3, istart, jstart, isize,& +& jsize implicit none ! subroutine arguments. integer(kind=inttype), intent(in) :: nn @@ -241,6 +247,8 @@ subroutine bcsymm2ndhalo(nn) ! laminar and eddy viscosity in the halo. gamma0(i, j) = gamma3(i, j) pp0(i, j) = pp3(i, j) + d2wall0(i, j) = d2wall3(i, j) + if (useroughsa) ks0(i, j) = ks3(i, j) if (viscous) rlv0(i, j) = rlv3(i, j) if (eddymodel) rev0(i, j) = rev3(i, j) end do @@ -254,8 +262,9 @@ subroutine bcsymmpolar1sthalo(nn) ! case of a degenerate line, as this line is the axi-symmetric ! centerline. this routine does just the 1st level halo. use constants + use inputphysics, only : useroughsa use bcpointers, only : ww1, ww2, pp1, pp2, rlv1, rlv2, rev1, rev2, & -& xx, istart, jstart, isize, jsize +& xx, istart, jstart, isize, jsize, d2wall1, d2wall2, ks1, ks2 use flowvarrefstate, only : viscous, eddymodel implicit none ! subroutine arguments. @@ -307,6 +316,8 @@ subroutine bcsymmpolar1sthalo(nn) ! set the pressure and possibly the laminar and ! eddy viscosity in the halo. pp1(i, j) = pp2(i, j) + d2wall1(i, j) = d2wall2(i, j) + if (useroughsa) ks1(i, j) = ks2(i, j) if (viscous) rlv1(i, j) = rlv2(i, j) if (eddymodel) rev1(i, j) = rev2(i, j) end do @@ -320,8 +331,9 @@ subroutine bcsymmpolar2ndhalo(nn) ! case of a degenerate line, as this line is the axi-symmetric ! centerline. this routine does just the 2nd level halo. use constants + use inputphysics, only : useroughsa use bcpointers, only : ww0, ww3, pp0, pp3, rlv0, rlv3, rev0, rev3, & -& xx, istart, jstart, isize, jsize +& d2wall0, d2wall3, ks0, ks3, xx, istart, jstart, isize, jsize use flowvarrefstate, only : viscous, eddymodel implicit none ! subroutine arguments. @@ -371,6 +383,8 @@ subroutine bcsymmpolar2ndhalo(nn) ! set the pressure and possibly the laminar and ! eddy viscosity in the halo. pp0(i, j) = pp3(i, j) + d2wall0(i, j) = d2wall3(i, j) + if (useroughsa) ks0(i, j) = ks3(i, j) if (viscous) rlv0(i, j) = rlv3(i, j) if (eddymodel) rev0(i, j) = rev3(i, j) end do diff --git a/src/adjoint/outputReverseFast/sa_fast_b.f90 b/src/adjoint/outputReverseFast/sa_fast_b.f90 index a19e6d3de..2e320c0a3 100644 --- a/src/adjoint/outputReverseFast/sa_fast_b.f90 +++ b/src/adjoint/outputReverseFast/sa_fast_b.f90 @@ -37,6 +37,7 @@ subroutine sasource_fast_b() real(kind=realtype), parameter :: f23=two*third ! local variables. integer(kind=inttype) :: i, j, k, nn, ii + real(kind=realtype) :: distrough real(kind=realtype) :: fv1, fv2, ft2 real(kind=realtype) :: fv1d, fv2d, ft2d real(kind=realtype) :: ss, sst, nu, dist2inv, chi, chi2, chi3 @@ -173,12 +174,26 @@ subroutine sasource_fast_b() ! and nu) and the functions fv1 and fv2. the latter corrects ! the production term near a viscous wall. nu = rlv(i, j, k)/w(i, j, k, irho) - dist2inv = one/d2wall(i, j, k)**2 chi = w(i, j, k, itu1)/nu + if (.not.useroughsa) then + dist2inv = one/d2wall(i, j, k)**2 + else + distrough = d2wall(i, j, k) + 0.03_realtype*ks(i, j, k) + dist2inv = one/distrough**2 + chi = chi + rsacr1*ks(i, j, k)/distrough + end if chi2 = chi*chi chi3 = chi*chi2 fv1 = chi3/(chi3+cv13) - fv2 = one - chi/(one+chi*fv1) + if (.not.useroughsa) then + fv2 = one - chi/(one+chi*fv1) +myIntPtr = myIntPtr + 1 + myIntStack(myIntPtr) = 0 + else + fv2 = one - w(i, j, k, itu1)/(nu+w(i, j, k, itu1)*fv1) +myIntPtr = myIntPtr + 1 + myIntStack(myIntPtr) = 1 + end if ! the function ft2, which is designed to keep a laminar ! solution laminar. when running in fully turbulent mode ! this function should be set to 0.0. @@ -313,16 +328,29 @@ subroutine sasource_fast_b() else chi2d = 0.0_8 end if - tempd = -(fv2d/(one+chi*fv1)) - chid = tempd - tempd0 = -(chi*tempd/(one+chi*fv1)) - fv1d = chi*tempd0 +branch = myIntStack(myIntPtr) + myIntPtr = myIntPtr - 1 + if (branch .eq. 0) then + tempd = -(fv2d/(one+chi*fv1)) + tempd0 = -(chi*tempd/(one+chi*fv1)) + chid = tempd + fv1*tempd0 + fv1d = chi*tempd0 + nud = 0.0_8 + else + temp0 = w(i, j, k, itu1) + temp = nu + temp0*fv1 + tempd = w(i, j, k, itu1)*fv2d/temp**2 + wd(i, j, k, itu1) = wd(i, j, k, itu1) + fv1*tempd - fv2d/temp + nud = tempd + fv1d = temp0*tempd + chid = 0.0_8 + end if tempd = fv1d/(cv13+chi3) chi3d = (1.0-chi3/(cv13+chi3))*tempd chi2d = chi2d + chi*chi3d - chid = chid + fv1*tempd0 + chi2*chi3d + 2*chi*chi2d + chid = chid + chi2*chi3d + 2*chi*chi2d wd(i, j, k, itu1) = wd(i, j, k, itu1) + chid/nu - nud = -(w(i, j, k, itu1)*chid/nu**2) + nud = nud - w(i, j, k, itu1)*chid/nu**2 temp = w(i, j, k, irho) rlvd(i, j, k) = rlvd(i, j, k) + nud/temp wd(i, j, k, irho) = wd(i, j, k, irho) - rlv(i, j, k)*nud/temp**2 @@ -444,6 +472,7 @@ subroutine sasource() real(kind=realtype), parameter :: f23=two*third ! local variables. integer(kind=inttype) :: i, j, k, nn, ii + real(kind=realtype) :: distrough real(kind=realtype) :: fv1, fv2, ft2 real(kind=realtype) :: ss, sst, nu, dist2inv, chi, chi2, chi3 real(kind=realtype) :: rr, gg, gg6, termfw, fwsa, term1, term2 @@ -560,12 +589,22 @@ subroutine sasource() ! and nu) and the functions fv1 and fv2. the latter corrects ! the production term near a viscous wall. nu = rlv(i, j, k)/w(i, j, k, irho) - dist2inv = one/d2wall(i, j, k)**2 chi = w(i, j, k, itu1)/nu + if (.not.useroughsa) then + dist2inv = one/d2wall(i, j, k)**2 + else + distrough = d2wall(i, j, k) + 0.03_realtype*ks(i, j, k) + dist2inv = one/distrough**2 + chi = chi + rsacr1*ks(i, j, k)/distrough + end if chi2 = chi*chi chi3 = chi*chi2 fv1 = chi3/(chi3+cv13) - fv2 = one - chi/(one+chi*fv1) + if (.not.useroughsa) then + fv2 = one - chi/(one+chi*fv1) + else + fv2 = one - w(i, j, k, itu1)/(nu+w(i, j, k, itu1)*fv1) + end if ! the function ft2, which is designed to keep a laminar ! solution laminar. when running in fully turbulent mode ! this function should be set to 0.0. diff --git a/src/adjoint/outputReverseFast/turbBCRoutines_fast_b.f90 b/src/adjoint/outputReverseFast/turbBCRoutines_fast_b.f90 index aacda3694..16d4465f5 100644 --- a/src/adjoint/outputReverseFast/turbBCRoutines_fast_b.f90 +++ b/src/adjoint/outputReverseFast/turbBCRoutines_fast_b.f90 @@ -206,6 +206,7 @@ subroutine bceddywall(nn) ! local variables. ! integer(kind=inttype) :: i, j + real(kind=realtype) :: fact ! determine the face id on which the subface is located and ! loop over the faces of the subface and set the eddy viscosity ! in the halo cells. @@ -213,37 +214,43 @@ subroutine bceddywall(nn) case (imin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(1, i, j) = -rev(2, i, j) + call saroughfact(2, i, j, fact) + rev(1, i, j) = fact*rev(2, i, j) end do end do case (imax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(ie, i, j) = -rev(il, i, j) + call saroughfact(il, i, j, fact) + rev(ie, i, j) = fact*rev(il, i, j) end do end do case (jmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(i, 1, j) = -rev(i, 2, j) + call saroughfact(i, 2, j, fact) + rev(i, 1, j) = fact*rev(i, 2, j) end do end do case (jmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(i, je, j) = -rev(i, jl, j) + call saroughfact(i, jl, j, fact) + rev(i, je, j) = fact*rev(i, jl, j) end do end do case (kmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(i, j, 1) = -rev(i, j, 2) + call saroughfact(i, j, 2, fact) + rev(i, j, 1) = fact*rev(i, j, 2) end do end do case (kmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - rev(i, j, ke) = -rev(i, j, kl) + call saroughfact(i, j, kl, fact) + rev(i, j, ke) = fact*rev(i, j, kl) end do end do end select @@ -632,7 +639,7 @@ subroutine bcturbwall(nn) ! local variables. ! integer(kind=inttype) :: i, j, ii, jj, iimax, jjmax - real(kind=realtype) :: tmpd, tmpe, tmpf, nu + real(kind=realtype) :: tmpd, tmpe, tmpf, nu, fact real(kind=realtype), dimension(:, :, :, :), pointer :: bmt real(kind=realtype), dimension(:, :, :), pointer :: bvt, ww2 real(kind=realtype), dimension(:, :), pointer :: rlv2, dd2wall @@ -661,37 +668,43 @@ subroutine bcturbwall(nn) case (imin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmti1(i, j, itu1, itu1) = one + call saroughfact(2, i, j, fact) + bmti1(i, j, itu1, itu1) = -fact end do end do case (imax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmti2(i, j, itu1, itu1) = one + call saroughfact(il, i, j, fact) + bmti2(i, j, itu1, itu1) = -fact end do end do case (jmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtj1(i, j, itu1, itu1) = one + call saroughfact(i, 2, j, fact) + bmtj1(i, j, itu1, itu1) = -fact end do end do case (jmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtj2(i, j, itu1, itu1) = one + call saroughfact(i, jl, j, fact) + bmtj2(i, j, itu1, itu1) = -fact end do end do case (kmin) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtk1(i, j, itu1, itu1) = one + call saroughfact(i, j, 2, fact) + bmtk1(i, j, itu1, itu1) = -fact end do end do case (kmax) do j=bcdata(nn)%jcbeg,bcdata(nn)%jcend do i=bcdata(nn)%icbeg,bcdata(nn)%icend - bmtk2(i, j, itu1, itu1) = one + call saroughfact(i, j, kl, fact) + bmtk2(i, j, itu1, itu1) = -fact end do end do end select @@ -1170,5 +1183,31 @@ subroutine turbbcnswall(secondhalo) end do bocos end subroutine turbbcnswall + subroutine saroughfact(i, j, k, fact) +! returns either the regular sa-boundary condition +! or the modified roughness-boundary condition + use constants + use inputphysics, only : useroughsa + use blockpointers, only : ks, d2wall, il, jl, kl + implicit none +! local variablse + integer(kind=inttype), intent(in) :: i, j, k + real(kind=realtype), intent(out) :: fact + if (.not.useroughsa) then + fact = -one + return + else + fact = (ks(i, j, k)-d2wall(i, j, k)/0.03_realtype)/(ks(i, j, k)+& +& d2wall(i, j, k)/0.03_realtype) + if (ks(i, j, k) .eq. 0.01 .or. d2wall(i, j, k) .eq. 0.01) print*, & +& i, j, k& +& , fact, & +& d2wall(i& +& , j, k)& +& , ks(i, & +& j, k) + end if + end subroutine saroughfact + end module turbbcroutines_fast_b diff --git a/src/adjoint/outputReverseFast/utils_fast_b.f90 b/src/adjoint/outputReverseFast/utils_fast_b.f90 index 09ee3bfa9..744c9bb53 100644 --- a/src/adjoint/outputReverseFast/utils_fast_b.f90 +++ b/src/adjoint/outputReverseFast/utils_fast_b.f90 @@ -671,12 +671,13 @@ subroutine setbcpointers(nn, spatialpointers) use blockpointers, only : w, p, rlv, rev, gamma, x, d2wall, & & si, sj, sk, s, globalcell, bcdata, nx, il, ie, ib, ny, jl, je, jb, & & nz, kl, ke, kb, bcfaceid, addgridvelocities, sfacei, sfacej, sfacek,& -& addgridvelocities +& addgridvelocities, d2wall, ks use bcpointers, only : ww0, ww1, ww2, ww3, pp0, pp1, pp2, pp3, rlv0,& & rlv1, rlv2, rlv3, rev0, rev1, rev2, rev3, gamma0, gamma1, gamma2, & & gamma3, gcp, xx, ss, ssi, ssj, ssk, dd2wall, sface, istart, iend, & -& jstart, jend, isize, jsize - use inputphysics, only : cpmodel, equations +& jstart, jend, isize, jsize, d2wall0, d2wall1, d2wall2, d2wall3, ks0,& +& ks1, ks2, ks3 + use inputphysics, only : cpmodel, equations, useroughsa implicit none ! subroutine arguments. integer(kind=inttype), intent(in) :: nn @@ -711,6 +712,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(2, 1:, 1:) rev1 => rev(1, 1:, 1:) rev0 => rev(0, 1:, 1:) + d2wall3 => d2wall(3, 1:, 1:) + d2wall2 => d2wall(2, 1:, 1:) + d2wall1 => d2wall(1, 1:, 1:) + d2wall0 => d2wall(0, 1:, 1:) + if (useroughsa) then + ks3 => ks(3, 1:, 1:) + ks2 => ks(2, 1:, 1:) + ks1 => ks(1, 1:, 1:) + ks0 => ks(0, 1:, 1:) + end if gamma3 => gamma(3, 1:, 1:) gamma2 => gamma(2, 1:, 1:) gamma1 => gamma(1, 1:, 1:) @@ -734,6 +745,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(il, 1:, 1:) rev1 => rev(ie, 1:, 1:) rev0 => rev(ib, 1:, 1:) + d2wall3 => d2wall(nx, 1:, 1:) + d2wall2 => d2wall(il, 1:, 1:) + d2wall1 => d2wall(ie, 1:, 1:) + d2wall0 => d2wall(ib, 1:, 1:) + if (useroughsa) then + ks3 => ks(nx, 1:, 1:) + ks2 => ks(il, 1:, 1:) + ks1 => ks(ie, 1:, 1:) + ks0 => ks(ib, 1:, 1:) + end if gamma3 => gamma(nx, 1:, 1:) gamma2 => gamma(il, 1:, 1:) gamma1 => gamma(ie, 1:, 1:) @@ -757,6 +778,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(1:, 2, 1:) rev1 => rev(1:, 1, 1:) rev0 => rev(1:, 0, 1:) + d2wall3 => d2wall(1:, 3, 1:) + d2wall2 => d2wall(1:, 2, 1:) + d2wall1 => d2wall(1:, 1, 1:) + d2wall0 => d2wall(1:, 0, 1:) + if (useroughsa) then + ks3 => ks(1:, 3, 1:) + ks2 => ks(1:, 2, 1:) + ks1 => ks(1:, 1, 1:) + ks0 => ks(1:, 0, 1:) + end if gamma3 => gamma(1:, 3, 1:) gamma2 => gamma(1:, 2, 1:) gamma1 => gamma(1:, 1, 1:) @@ -780,6 +811,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(1:, jl, 1:) rev1 => rev(1:, je, 1:) rev0 => rev(1:, jb, 1:) + d2wall3 => d2wall(1:, ny, 1:) + d2wall2 => d2wall(1:, jl, 1:) + d2wall1 => d2wall(1:, je, 1:) + d2wall0 => d2wall(1:, jb, 1:) + if (useroughsa) then + ks3 => ks(1:, ny, 1:) + ks2 => ks(1:, jl, 1:) + ks1 => ks(1:, je, 1:) + ks0 => ks(1:, jb, 1:) + end if gamma3 => gamma(1:, ny, 1:) gamma2 => gamma(1:, jl, 1:) gamma1 => gamma(1:, je, 1:) @@ -803,6 +844,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(1:, 1:, 2) rev1 => rev(1:, 1:, 1) rev0 => rev(1:, 1:, 0) + d2wall3 => d2wall(1:, 1:, 3) + d2wall2 => d2wall(1:, 1:, 2) + d2wall1 => d2wall(1:, 1:, 1) + d2wall0 => d2wall(1:, 1:, 0) + if (useroughsa) then + ks3 => ks(1:, 1:, 3) + ks2 => ks(1:, 1:, 2) + ks1 => ks(1:, 1:, 1) + ks0 => ks(1:, 1:, 0) + end if gamma3 => gamma(1:, 1:, 3) gamma2 => gamma(1:, 1:, 2) gamma1 => gamma(1:, 1:, 1) @@ -826,6 +877,16 @@ subroutine setbcpointers(nn, spatialpointers) rev2 => rev(1:, 1:, kl) rev1 => rev(1:, 1:, ke) rev0 => rev(1:, 1:, kb) + d2wall3 => d2wall(1:, 1:, nz) + d2wall2 => d2wall(1:, 1:, kl) + d2wall1 => d2wall(1:, 1:, ke) + d2wall0 => d2wall(1:, 1:, kb) + if (useroughsa) then + ks3 => ks(1:, 1:, nz) + ks2 => ks(1:, 1:, kl) + ks1 => ks(1:, 1:, ke) + ks0 => ks(1:, 1:, kb) + end if gamma3 => gamma(1:, 1:, nz) gamma2 => gamma(1:, 1:, kl) gamma1 => gamma(1:, 1:, ke) diff --git a/src/bcdata/BCData.F90 b/src/bcdata/BCData.F90 index f8ebb836d..c57e3af9b 100644 --- a/src/bcdata/BCData.F90 +++ b/src/bcdata/BCData.F90 @@ -10,12 +10,32 @@ module BCData subroutine setBCVarNamesIsothermalWall use cgnsNames use constants + use inputPhysics, only: useRoughSA implicit none nbcVar = nbcVarIsothermalWall bcVarNames(1) = cgnsTemp + if (useRoughSA) then + nbcVar = nbcVar + 1 + bcVarNames(2) = cgnsSandGrainRoughness + end if + end subroutine setBCVarNamesIsothermalWall + subroutine setBCVarNamesAdiabaticWall + use cgnsNames + use constants + use inputPhysics, only: useRoughSA + implicit none + nbcVar = nbcVarAdiabaticWall + + if (useRoughSA) then + nbcVar = nbcVar + 1 + bcVarNames(1) = cgnsSandGrainRoughness + end if + + end subroutine setBCVarNamesAdiabaticWall + subroutine setBCVarNamesSubsonicInflow use constants use cgnsNames @@ -424,6 +444,7 @@ subroutine BCDataIsothermalWall(boco, bcVarArray, iBeg, iEnd, jBeg, jEnd) #ifndef USE_TAPENADE use commonFormats, only: strings #endif + use inputPhysics, only: useRoughSA implicit none ! ! Subroutine arguments. @@ -467,8 +488,62 @@ subroutine BCDataIsothermalWall(boco, bcVarArray, iBeg, iEnd, jBeg, jEnd) end do end do + ! Set a value of 0 if it was not possible to determine the + ! sand grain roughness + + if (useRoughSA) then + ! Set a value of 0 if it was not possible to determine the + ! sand grain roughness + if (.not. bcVarPresent(1)) then + bcVarArray(:, :, 2) = zero + end if + + do j = jBeg, jEnd + do i = iBeg, iEnd + BCData(boco)%ksNS_Wall(i, j) = bcVarArray(i, j, 2) + end do + end do + end if + end subroutine BCDataIsothermalWall + subroutine BCDataAdiabaticWall(boco, bcVarArray, iBeg, iEnd, jBeg, jEnd) + ! + ! Tries to extract the equivalent sand grain roughness. It sets + ! a default value of 0.0 + ! + use constants + use cgnsNames + use inputPhysics, only: useRoughSA + use blockPointers, only: BCFaceID, BCData, nBKGlobal + implicit none + ! + ! Subroutine arguments. + ! + integer(kind=intType) :: boco + integer(kind=intType) :: iBeg, iEnd, jBeg, jEnd + real(kind=realType), dimension(iBeg:iEnd, jBeg:jEnd, nbcVarMax) :: bcVarArray + ! + ! Local variables. + ! + integer(kind=intType) :: i, j + + if (useRoughSA) then + ! Set a value of 0 if it was not possible to determine the + ! sand grain roughness + if (.not. bcVarPresent(1)) then + bcVarArray(:, :, 1) = zero + end if + + do j = jBeg, jEnd + do i = iBeg, iEnd + BCData(boco)%ksNS_Wall(i, j) = bcVarArray(i, j, 1) + end do + end do + end if + + end subroutine BCDataAdiabaticWall + subroutine BCDataSubsonicInflow(boco, bcVarArray, iBeg, iEnd, jBeg, jEnd, allTurbPresent) ! ! BCDataSubsonicInflow tries to extract the prescribed data @@ -1452,6 +1527,9 @@ subroutine setBCData(bcDataNamesIn, bcDataIn, famLists, sps, & select case (BCType(j)) + case (NSWallAdiabatic) + call setBCVarNamesAdiabaticWall + call errorCheckbcDataNamesIn("NSWallAdiabatic", bcDataNamesIn) case (NSWallIsothermal) call setBCVarNamesSupersonicInflow call errorCheckbcDataNamesIn("NSWallIsothermal", bcDataNamesIn) @@ -1550,6 +1628,9 @@ subroutine setBCData_d(bcDataNamesIn, bcDataIn, bcDataInd, famLists, sps, & select case (BCType(j)) + case (NSWallAdiabatic) + call setBCVarNamesAdiabaticWall + call errorCheckbcDataNamesIn("NSWallAdiabatic", bcDataNamesIn) case (NSWallIsothermal) call setBCVarNamesSupersonicInflow call errorCheckbcDataNamesIn("NSWallIsothermal", bcDataNamesIn) @@ -1655,6 +1736,9 @@ subroutine setBCData_b(bcDataNamesIn, bcDataIn, bcDataInd, famLists, sps, & select case (BCType(j)) + case (NSWallAdiabatic) + call setBCVarNamesAdiabaticWall + call errorCheckbcDataNamesIn("NSWallAdiabatic", bcDataNamesIn) case (NSWallIsothermal) call setBCVarNamesSupersonicInflow call errorCheckbcDataNamesIn("NSWallIsothermal", bcDataNamesIn) @@ -2181,6 +2265,7 @@ subroutine allocMemBCData use blockPointers, only: BCData, flowDoms, nBocos, nDom, BCType use flowVarRefState, only: nt1, nt2 use inputTimeSpectral, only: nTimeIntervalsSpectral + use inputPhysics, only: useRoughSA use iteration, only: nALESteps use utils, only: setPointers, terminate implicit none @@ -2250,6 +2335,14 @@ subroutine allocMemBCData BCData(mm)%area(iNodeBeg + 1:iNodeEnd, jNodeBeg + 1:jNodeEnd), & BCData(mm)%CpTarget(iNodeBeg:iNodeEnd, jNodeBeg:jNodeEnd), & stat=ierr) + if (useRoughSA .and. ierr == 0) then + allocate (BCData(mm)%ksNS_Wall(iBeg:iEnd, jBeg:jEnd), stat=ierr) + if (level > 1) then + ! The extrapolation of the BC for MG does not work + ! properly. Thus it must be initialized with zero + BCData(mm)%ksNS_Wall = zero + end if + end if if (ierr /= 0) & call terminate("allocMemBCData", & "Memory allocation failure for & @@ -2273,6 +2366,14 @@ subroutine allocMemBCData BCData(mm)%area(iNodeBeg + 1:iNodeEnd, jNodeBeg + 1:jNodeEnd), & BCData(mm)%CpTarget(iNodeBeg:iNodeEnd, jNodeBeg:jNodeEnd), & stat=ierr) + if (useRoughSA .and. ierr == 0) then + allocate (BCData(mm)%ksNS_Wall(iBeg:iEnd, jBeg:jEnd), stat=ierr) + if (level > 1) then + ! The extrapolation of the BC for MG does not work + ! properly. Thus it must be initialized with zero + BCData(mm)%ksNS_Wall = zero + end if + end if if (ierr /= 0) & call terminate("allocMemBCData", & "Memory allocation failure for & @@ -2632,6 +2733,7 @@ subroutine initBCData nullify (BCData(j)%surfIndex) nullify (BCData(j)%uSlip) nullify (BCData(j)%TNS_Wall) + nullify (BCData(j)%ksNS_Wall) nullify (BCData(j)%CpTarget) nullify (BCData(j)%normALE) @@ -2756,6 +2858,11 @@ subroutine setBCDataFineGrid(initializationPart) select case (BCType(j)) + case (NSWallAdiabatic) + call setBCVarNamesAdiabaticWall ! sets bcVarNames and nbcVar + call extractFromDataSet(bcVarArray) + call BCDataAdiabaticWall(j, bcVarArray, iBeg, iEnd, jBeg, jEnd) + case (NSWallIsothermal) call setBCVarNamesIsothermalWall ! sets bcVarNames and nbcVar call extractFromDataSet(bcVarArray) @@ -3010,6 +3117,12 @@ subroutine setBCDataFineGrid_d(initializationPart) ! call the appropriate routine. select case (BCType(j)) + ! This would be needed if wall roughness is differentiated + ! case (NSWallAdiabatic) + ! call setBCVarNamesAdiabaticWall ! sets bcVarNames and nbcVar + ! call extractFromDataSet_d(bcVarArray, bcVarArrayd) + ! call BCDataAdiabaticWall_d(j, bcVarArray, bcVarArrayd, iBeg, iEnd, jBeg, jEnd) + case (NSWallIsothermal) call setBCVarNamesIsothermalWall ! sets bcVarNames and nbcVar call extractFromDataSet_d(bcVarArray, bcVarArrayd) @@ -3106,6 +3219,13 @@ subroutine setBCDataFineGrid_b(initializationPart) ! call the appropriate routine. select case (BCType(j)) + ! This would be needed if wall roughness is differentiated + ! case (NSWallAdiabatic) + ! call setBCVarNamesAdiabaticWall ! sets bcVarNames and nbcVar + ! call extractFromDataSet(bcVarArray) + ! call BCDataAdiabaticWall_b(j, bcVarArray, bcVarArrayd, iBeg, iEnd, jBeg, jEnd) + ! call extractFromDataSet_b(bcVarArray, bcVarArrayd) + case (NSWallIsothermal) call setBCVarNamesIsothermalWall ! sets bcVarNames and nbcVar call extractFromDataSet(bcVarArray) diff --git a/src/f2py/adflow.pyf b/src/f2py/adflow.pyf index a5a0cc223..e41de1abd 100644 --- a/src/f2py/adflow.pyf +++ b/src/f2py/adflow.pyf @@ -260,6 +260,9 @@ python module libadflow subroutine updatewalldistancealllevels end subroutine updatewalldistancealllevels + subroutine updatewallroughness + end subroutine updatewallroughness + end module walldistance module initializeflow @@ -756,6 +759,12 @@ python module libadflow integer(kind=inttype), optional,intent(in),check(len(blocks)>=nblocks),depend(blocks) :: nblocks=len(blocks) end subroutine updaterotationrate + subroutine updatesurfaceroughness(ks_in, famlist, nfamlist) ! in :test:updatesurfaceroughness.f90 + real(kind=realtype) ,intent(in) :: ks_in + integer(kind=inttype) dimension(nfamlist),intent(in) :: famlist + integer(kind=inttype), optional,intent(in),check(len(famlist)>=nfamlist),depend(famlist) :: nfamlist=len(famlist) + end subroutine updatesurfaceroughness + subroutine preprocessingoverset(flag,n, closedfamlist, nfam) ! in :test:preprocessingAPI.F90:preprocessingapi integer(kind=inttype) dimension(n) :: flag integer(kind=inttype), optional,intent(in),check(len(flag)>=n),depend(flag) :: n=len(flag) @@ -1202,6 +1211,7 @@ python module libadflow real(kind=realtype) :: beta integer(kind=inttype) :: liftindex real(kind=realtype) :: cavitationnumber + logical :: useroughsa real(kind=realtype) :: cpmin_rho end module inputphysics diff --git a/src/inputParam/inputParamRoutines.F90 b/src/inputParam/inputParamRoutines.F90 index 76dc34e48..a86c877dd 100644 --- a/src/inputParam/inputParamRoutines.F90 +++ b/src/inputParam/inputParamRoutines.F90 @@ -2508,6 +2508,7 @@ subroutine volumeVariables(variables) use constants use extraOutput use utils, only: convertToLowerCase, terminate + use inputPhysics, only: useRoughSA implicit none ! ! Subroutine arguments. @@ -2559,6 +2560,8 @@ subroutine volumeVariables(variables) volWriteStatus = .false. volWriteIntermittency = .false. + volWriteKs = .false. + ! Initialize nVarSpecified to 0. This serves as a test ! later on. @@ -2709,6 +2712,15 @@ subroutine volumeVariables(variables) volWriteIntermittency = .true. nVarSpecified = nVarSpecified + 1 + case ("ks") + if (.not. useRoughSA) then + call terminate("volumeVariables", "Can not export surface roughness & + &values ('volumeVariables': ['ks']) when the rough SA variant is not & + &used (useRoughSA = False)") + end if + volWriteKs = .true. + nVarSpecified = nVarSpecified + 1 + case default pos = len_trim(keyword) write (errorMessage, "(3a)") "Unknown extra volume output & diff --git a/src/modules/BCPointers.F90 b/src/modules/BCPointers.F90 index 39b8c6245..f52eda2e8 100644 --- a/src/modules/BCPointers.F90 +++ b/src/modules/BCPointers.F90 @@ -10,6 +10,8 @@ module BCPointers real(kind=realType), dimension(:, :, :), pointer :: ww0, ww1, ww2, ww3 real(kind=realType), dimension(:, :), pointer :: pp0, pp1, pp2, pp3 real(kind=realType), dimension(:, :), pointer :: rlv0, rlv1, rlv2, rlv3 + real(kind=realType), dimension(:, :), pointer :: d2wall0, d2wall1, d2wall2, d2wall3 + real(kind=realType), dimension(:, :), pointer :: ks0, ks1, ks2, ks3 real(kind=realType), dimension(:, :), pointer :: rev0, rev1, rev2, rev3 real(kind=realType), dimension(:, :), pointer :: gamma0, gamma1, gamma2, gamma3 real(kind=realType), dimension(:, :, :), pointer :: ssi, ssj, ssk @@ -25,6 +27,7 @@ module BCPointers real(kind=realType), dimension(:, :), pointer :: pp0d, pp1d, pp2d, pp3d real(kind=realType), dimension(:, :), pointer :: rlv0d, rlv1d, rlv2d, rlv3d real(kind=realType), dimension(:, :), pointer :: rev0d, rev1d, rev2d, rev3d + real(kind=realType), dimension(:, :), pointer :: d2wall0d, d2wall1d, d2wall2d, d2wall3d real(kind=realType), dimension(:, :), pointer :: gamma0d, gamma1d, gamma2d, gamma3d real(kind=realType), dimension(:, :, :), pointer :: ssid, ssjd, sskd, xxd real(kind=realType), dimension(:, :, :), pointer :: ssd diff --git a/src/modules/block.F90 b/src/modules/block.F90 index 1fdb9b3fe..ab3b66078 100644 --- a/src/modules/block.F90 +++ b/src/modules/block.F90 @@ -96,9 +96,11 @@ module block ! uSlip(:,:,3): the 3 components of the velocity vector on ! a viscous wall. ! TNS_Wall(:,:): Wall temperature for isothermal walls. + ! ksNS_Wall(:,:): Equivalent Sand Grain Roughness on viscous walls. real(kind=realType), dimension(:, :, :), pointer :: uSlip real(kind=realType), dimension(:, :), pointer :: TNS_Wall + real(kind=realType), dimension(:, :), pointer :: ksNS_Wall ! The name of this boundary condition and it's index character(maxCGNSNameLen) :: family @@ -656,12 +658,19 @@ module block ! ! Turbulence model variables. ! - ! d2Wall(2:il,2:jl,2:kl) - Distance from the center of the cell - ! to the nearest viscous wall. + ! d2Wall(0:ib, 0:jb, 0:kb) - Distance from the center of the cell + ! to the nearest viscous wall. It is exchanged for non-BC halo cells and extrapolated + ! for symmetry type BCs. For other BCs, this value is initialize to a large number ! intermittency( ) - Function defining the transition location + ! + ! The next two variables are only initialized if roughness is requested (useRoughSA = True) + ! nearestWallCellInd(2:il,2:jl,2:kl) - global cell ID for the nearest wall cell; is needed for rougness + ! ks(0:ib, 0:jb, 0:kb) - Roughness value of the nearest wall - see d2wall description for the values set real(kind=realType), dimension(:, :, :), pointer :: d2Wall, filterDES real(kind=realType), dimension(:, :, :), pointer :: intermittency + integer(kind=intType), dimension(:, :, :), pointer :: nearestWallCellInd + real(kind=realType), dimension(:, :, :), pointer :: ks ! bmti1(je,ke,nt1:nt2,nt1:nt2): Matrix used for the implicit ! boundary condition treatment of diff --git a/src/modules/blockPointers.F90 b/src/modules/blockPointers.F90 index 4705f9fd7..16f2b3c6a 100644 --- a/src/modules/blockPointers.F90 +++ b/src/modules/blockPointers.F90 @@ -152,6 +152,7 @@ module blockPointers real(kind=realType), dimension(:, :, :), pointer :: radI, radJ, radK real(kind=realType), dimension(:, :, :), pointer :: d2Wall + real(kind=realType), dimension(:, :, :), pointer :: ks real(kind=realType), dimension(:, :, :), pointer :: intermittency real(kind=realType), dimension(:, :, :), pointer :: filterDES ! eran-des real(kind=realType), dimension(:, :, :, :), pointer :: bmti1 diff --git a/src/modules/cgnsNames.f90 b/src/modules/cgnsNames.f90 index c3c67549e..02d8c5164 100644 --- a/src/modules/cgnsNames.f90 +++ b/src/modules/cgnsNames.f90 @@ -171,6 +171,9 @@ module cgnsNames character(len=maxCGNSNameLen), parameter :: & cgnsIntermittency = "Intermittency" + character(len=maxCGNSNameLen), parameter :: & + cgnsSandGrainRoughness = "SandGrainRoughness" + ! ! Residual names. ! diff --git a/src/modules/constants.F90 b/src/modules/constants.F90 index 086240822..730bccf18 100644 --- a/src/modules/constants.F90 +++ b/src/modules/constants.F90 @@ -300,6 +300,7 @@ module constants integer(kind=intType), parameter :: nbcVarSubsonicInflow = 17 integer(kind=intType), parameter :: nbcVarSubsonicOutflow = 1 integer(kind=intType), parameter :: nbcVarSupersonicInflow = 7 + integer(kind=intType), parameter :: nbcVarAdiabaticWall = 0 integer(kind=intType), parameter :: nbcVarIsothermalWall = 1 ! Indices of specific familyExcahnge groups based on BC diff --git a/src/modules/extraOutput.f90 b/src/modules/extraOutput.f90 index 8a6e33e1e..78fdc9d03 100644 --- a/src/modules/extraOutput.f90 +++ b/src/modules/extraOutput.f90 @@ -36,6 +36,7 @@ module extraOutput logical :: volWriteResRhoE, volWriteResTurb, volWriteBlank logical :: volWriteShock, volWriteFilteredShock, volWriteGC, volWriteStatus logical :: volWriteIntermittency + logical :: volWriteKs ! ! The logical variables, which define the isosurface variables ! to be written. diff --git a/src/modules/inputParam.F90 b/src/modules/inputParam.F90 index 9afa9ccaf..0d6a6a7ec 100644 --- a/src/modules/inputParam.F90 +++ b/src/modules/inputParam.F90 @@ -529,6 +529,7 @@ module inputPhysics ! when considering turbulence model effects ! useRotationSA: Determines if we will use rotation correction (SA model only) ! useft2SA: Determines if we will use the ft2 term (SA model only) + ! useRoughSA: Whether or not to use rough version of SA (BC values are set via CGNS-Grid) ! wallFunctions: Whether or not to use wall functions. ! wallDistanceNeeded: Whether or not the wall distance is needed ! for the turbulence model in a RANS problem. @@ -596,6 +597,7 @@ module inputPhysics real(kind=realType), dimension(3, 2) :: momentAxis real(kind=realType) :: SSuthDim, muSuthDim, TSuthDim real(kind=realType) :: cavitationnumber + logical :: useRoughSA real(kind=realType) :: cpmin_rho real(kind=realType), dimension(:), allocatable :: cpmin_family diff --git a/src/modules/paramTurb.F90 b/src/modules/paramTurb.F90 index db7a162a6..9adf41ae9 100644 --- a/src/modules/paramTurb.F90 +++ b/src/modules/paramTurb.F90 @@ -24,6 +24,7 @@ module paramTurb real(kind=realType), parameter :: rsaCt3 = 1.2_realType real(kind=realType), parameter :: rsaCt4 = 0.5_realType real(kind=realType), parameter :: rsaCrot = 2.0_realType + real(kind=realType), parameter :: rsaCr1 = 0.5_realType ! ! K-omega constants. diff --git a/src/modules/wallDistanceData.F90 b/src/modules/wallDistanceData.F90 index cb388b5a5..27b809c8f 100644 --- a/src/modules/wallDistanceData.F90 +++ b/src/modules/wallDistanceData.F90 @@ -43,4 +43,6 @@ module wallDistanceData real(kind=realType), dimension(:), pointer :: xVolume #endif + integer(kind=intType), dimension(:, :), allocatable :: nCellBlockOffset + end module wallDistanceData diff --git a/src/output/outputMod.F90 b/src/output/outputMod.F90 index 1a954888b..016695f48 100644 --- a/src/output/outputMod.F90 +++ b/src/output/outputMod.F90 @@ -232,6 +232,8 @@ subroutine numberOfVolSolVariables(nVolSolvar, nVolDiscrVar) if (volWriteBlank) nVolDiscrVar = nVolDiscrVar + 1 + if (volwriteKs) nVolDiscrVar = nVolDiscrVar + 1 + end subroutine numberOfVolSolVariables subroutine copyDataBufSinglePrecision(val, buffer, & @@ -567,6 +569,11 @@ subroutine volSolNames(solNames) solNames(nn) = cgnsIntermittency end if + if (volWriteKs) then + nn = nn + 1 + solNames(nn) = cgnsSandGrainRoughness + end if + end subroutine volSolNames subroutine surfSolNames(solNames) @@ -1346,6 +1353,18 @@ subroutine storeSolInBuffer(buffer, copyInBuffer, solName, & end do end do + case (cgnsSandGrainRoughness) + ! It is only possible to write this when it was allocated in the first place + ! (useRoughSA = True) but this has been check in 'inputParamRoutines' + ! allready + do k = kBeg, kEnd + do j = jBeg, jEnd + do i = iBeg, iEnd + wIO(i, j, k, 1) = real(ks(i, j, k), realType) + end do + end do + end do + case default call terminate("storeSolInBuffer", & "This should not happen") diff --git a/src/preprocessing/preprocessingAPI.F90 b/src/preprocessing/preprocessingAPI.F90 index 6516357ec..c6f4098a6 100644 --- a/src/preprocessing/preprocessingAPI.F90 +++ b/src/preprocessing/preprocessingAPI.F90 @@ -19,6 +19,7 @@ subroutine preprocessing recvBufferSize_1to1, sendBufferSize_1to1, sendBufferSIzeOver, & recvBufferSizeOver, commPatternOverset, internalOverset, sendBuffer, & recvBuffer, sendBufferSize, recvBufferSize + use haloExchange, only: exchanged2Wall use inputPhysics use inputTimeSpectral use section @@ -31,6 +32,7 @@ subroutine preprocessing use coarseUtils, only: createCoarseBlocks use pointMatchedCommPattern, only: determineCommPattern use oversetAPI, only: oversetComm, determineClusters, determineViscousDirs + use wallDistanceData, only: nCellBlockOffset implicit none ! ! Local variables. @@ -208,6 +210,12 @@ subroutine preprocessing ! See the corresponding subroutine header, although the ! names are pretty self-explaining + ! Allocate Block-offset. SA rough might need it. It is filled in + ! 'setGlobalCellsAndNodes'. This function is called per level and thus it + ! must be allocated before the call + + allocate (nCellBlockOffset(nLevels, nDom)) + do level = 1, nLevels call xhalo(level) call allocateMetric(level) @@ -232,6 +240,9 @@ subroutine preprocessing ! be done and overset connectivity computed do level = 1, nLevels call computeWallDistance(level, .True.) + if (wallDistanceNeeded) then + call exchanged2Wall(level) + end if end do call preprocessingADjoint @@ -1918,6 +1929,7 @@ subroutine setGlobalCellsAndNodes(level) use inputTimeSpectral use utils, only: setPointers, terminate use haloExchange, only: whalo1to1intgeneric + use wallDistanceData, only: nCellBlockOffset implicit none ! Input variables @@ -1928,7 +1940,7 @@ subroutine setGlobalCellsAndNodes(level) integer(kind=intType) :: ierr, istart logical :: commPressure, commLamVis, commEddyVis, commGamma integer(kind=intType), dimension(nProc) :: nNodes, nCells, nCellOffset, nNodeOffset - integer(kind=intType), dimension(nDom) :: nCellBLockOffset, nNodeBLockOffset + integer(kind=intType), dimension(nDom) :: nNodeBLockOffset integer(kind=intType) :: npts, nCell, nNode integer(kind=intType), dimension(:), allocatable :: nNodesProc, cumNodesProc integer(kind=intTYpe), dimension(:), allocatable :: nCellsProc, cumCellsProc @@ -1995,11 +2007,11 @@ subroutine setGlobalCellsAndNodes(level) adflow_integer, 0, ADflow_comm_world, ierr) ! Determine the global cell number offset for each local block. - nCellBlockOffset(1) = nCellOffsetLocal(level) + nCellBlockOffset(level, 1) = nCellOffsetLocal(level) do nn = 2, nDom call setPointers(nn - 1, level, 1) - nCellBlockOffset(nn) = nCellBlockOffset(nn - 1) & - + nx * ny * nz + nCellBlockOffset(level, nn) = nCellBlockOffset(level, nn - 1) & + + nx * ny * nz end do ! Repeat for nodes. @@ -2026,7 +2038,7 @@ subroutine setGlobalCellsAndNodes(level) ! instances of a give block adjacent to each other in ! the matrix globalCell(i, j, k) = & - nCellBLockOffset(nn) * nTimeIntervalsSpectral + nx * ny * nz * (sps - 1) + & + nCellBLockOffset(level, nn) * nTimeIntervalsSpectral + nx * ny * nz * (sps - 1) + & (i - 2) + (j - 2) * nx + (k - 2) * nx * ny end do end do @@ -4356,4 +4368,41 @@ subroutine updateRotationRate(rotCenter, rotRate, blocks, nblocks) end subroutine updateRotationRate + subroutine updateSurfaceRoughness(ks_in, famList, nFamList) + + use constants + use blockPointers + use inputTimeSpectral, only: nTimeIntervalsSpectral + use utils, only: setPointers + use sorting, only: famInList + implicit none + + real(kind=realType), intent(in) :: ks_in + integer(kind=intType), intent(in) :: nFamList, famList(nFamList) + + integer(kind=intType) :: nLevels, level, sps, nn, mm + + nLevels = ubound(flowDoms, 2) + + do level = 1, nLevels + do sps = 1, nTimeIntervalsSpectral + do nn = 1, nDom + call setPointers(nn, level, sps) + + ! Loop over the number of boundary subfaces of this block. + do mm = 1, nBocos + + if (.not. famInList(BCData(mm)%famID, famList)) then + cycle + end if + + BCData(mm)%ksNS_Wall = ks_in + + end do + end do + end do + end do + + end subroutine updateSurfaceRoughness + end module preprocessingAPI diff --git a/src/solver/BCRoutines.F90 b/src/solver/BCRoutines.F90 index 9ce054802..4c48da790 100644 --- a/src/solver/BCRoutines.F90 +++ b/src/solver/BCRoutines.F90 @@ -234,8 +234,9 @@ subroutine bcSymm1stHalo(nn) use constants use blockPointers, only: BCdata use flowVarRefState, only: viscous, eddyModel + use inputPhysics, only: useRoughSA use BCPointers, only: gamma1, gamma2, ww1, ww2, pp1, pp2, rlv1, rlv2, & - iStart, jStart, iSize, jSize, rev1, rev2 + iStart, jStart, iSize, jSize, rev1, rev2, d2wall1, d2wall2, ks1, ks2 implicit none ! Subroutine arguments. @@ -274,6 +275,8 @@ subroutine bcSymm1stHalo(nn) gamma1(i, j) = gamma2(i, j) pp1(i, j) = pp2(i, j) + d2wall1(i, j) = d2wall2(i, j) + if (useRoughSA) ks1(i, j) = ks2(i, j) if (viscous) rlv1(i, j) = rlv2(i, j) if (eddyModel) rev1(i, j) = rev2(i, j) end do @@ -287,7 +290,8 @@ subroutine bcSymm2ndHalo(nn) use constants use blockPointers, only: BCdata use flowVarRefState, only: viscous, eddyModel - use BCPointers, only: gamma0, gamma3, ww0, ww3, pp0, pp3, rlv0, rlv3, & + use inputPhysics, only: useRoughSA + use BCPointers, only: gamma0, gamma3, ww0, ww3, pp0, pp3, rlv0, rlv3, d2wall0, d2wall3, ks0, ks3, & rev0, rev3, iStart, jStart, iSize, jSize implicit none @@ -323,6 +327,8 @@ subroutine bcSymm2ndHalo(nn) gamma0(i, j) = gamma3(i, j) pp0(i, j) = pp3(i, j) + d2wall0(i, j) = d2wall3(i, j) + if (useRoughSA) ks0(i, j) = ks3(i, j) if (viscous) rlv0(i, j) = rlv3(i, j) if (eddyModel) rev0(i, j) = rev3(i, j) end do @@ -339,8 +345,10 @@ subroutine bcSymmPolar1stHalo(nn) ! centerline. This routine does just the 1st level halo. use constants + use inputPhysics, only: useRoughSA use BCPointers, only: ww1, ww2, pp1, pp2, rlv1, rlv2, rev1, rev2, & - xx, iStart, jStart, iSize, jSize + xx, iStart, jStart, iSize, jSize, & + d2wall1, d2wall2, ks1, ks2 use flowVarRefState, only: viscous, eddyModel implicit none @@ -403,6 +411,8 @@ subroutine bcSymmPolar1stHalo(nn) ! eddy viscosity in the halo. pp1(i, j) = pp2(i, j) + d2wall1(i, j) = d2wall2(i, j) + if (useRoughSA) ks1(i, j) = ks2(i, j) if (viscous) rlv1(i, j) = rlv2(i, j) if (eddyModel) rev1(i, j) = rev2(i, j) end do @@ -418,7 +428,8 @@ subroutine bcSymmPolar2ndHalo(nn) ! centerline. This routine does just the 2nd level halo. use constants - use BCPointers, only: ww0, ww3, pp0, pp3, rlv0, rlv3, rev0, rev3, & + use inputPhysics, only: useRoughSA + use BCPointers, only: ww0, ww3, pp0, pp3, rlv0, rlv3, rev0, rev3, d2wall0, d2wall3, ks0, ks3, & xx, iStart, jStart, iSize, jSize use flowVarRefState, only: viscous, eddyModel implicit none @@ -480,6 +491,8 @@ subroutine bcSymmPolar2ndHalo(nn) ! eddy viscosity in the halo. pp0(i, j) = pp3(i, j) + d2wall0(i, j) = d2wall3(i, j) + if (useRoughSA) ks0(i, j) = ks3(i, j) if (viscous) rlv0(i, j) = rlv3(i, j) if (eddyModel) rev0(i, j) = rev3(i, j) end do diff --git a/src/turbulence/sa.F90 b/src/turbulence/sa.F90 index 7459158d4..0651b182b 100644 --- a/src/turbulence/sa.F90 +++ b/src/turbulence/sa.F90 @@ -106,6 +106,7 @@ subroutine saSource ! Local variables. integer(kind=intType) :: i, j, k, nn, ii + real(kind=realType) :: distRough real(kind=realType) :: fv1, fv2, ft2 real(kind=realType) :: ss, sst, nu, dist2Inv, chi, chi2, chi3 real(kind=realType) :: rr, gg, gg6, termFw, fwSa, term1, term2 @@ -243,12 +244,25 @@ subroutine saSource ! the production term near a viscous wall. nu = rlv(i, j, k) / w(i, j, k, irho) - dist2Inv = one / (d2Wall(i, j, k)**2) chi = w(i, j, k, itu1) / nu + + if (.not. useRoughSA) then + dist2Inv = one / (d2Wall(i, j, k)**2) + else + distRough = d2Wall(i, j, k) + 0.03_realType * ks(i, j, k) + dist2Inv = one / (distRough**2) + chi = chi + rsaCr1 * ks(i, j, k) / distRough + end if + chi2 = chi * chi chi3 = chi * chi2 fv1 = chi3 / (chi3 + cv13) - fv2 = one - chi / (one + chi * fv1) + + if (.not. useRoughSA) then + fv2 = one - chi / (one + chi * fv1) + else + fv2 = one - w(i, j, k, itu1) / (nu + w(i, j, k, itu1) * fv1) + end if ! The function ft2, which is designed to keep a laminar ! solution laminar. When running in fully turbulent mode @@ -307,7 +321,13 @@ subroutine saSource ! treatment. dfv1 = three * chi2 * cv13 / ((chi3 + cv13)**2) - dfv2 = (chi2 * dfv1 - one) / (nu * ((one + chi * fv1)**2)) + + if (.not. useRoughSA) then + dfv2 = (chi2 * dfv1 - one) / (nu * ((one + chi * fv1)**2)) + else + dfv2 = (w(i, j, k, itu1) * dfv1 - nu) / (nu + w(i, j, k, itu1) * fv1)**2 + end if + dft2 = -two * rsaCt4 * chi * ft2 / nu drr = (one - rr * (fv2 + w(i, j, k, itu1) * dfv2)) & diff --git a/src/turbulence/turbBCRoutines.F90 b/src/turbulence/turbBCRoutines.F90 index 24c7cadc9..4824f4134 100644 --- a/src/turbulence/turbBCRoutines.F90 +++ b/src/turbulence/turbBCRoutines.F90 @@ -320,6 +320,7 @@ subroutine bcEddyWall(nn) ! Local variables. ! integer(kind=intType) :: i, j + real(kind=realType) :: fact ! Determine the face id on which the subface is located and ! loop over the faces of the subface and set the eddy viscosity @@ -329,42 +330,48 @@ subroutine bcEddyWall(nn) case (iMin) do j = BCData(nn)%jcBeg, BCData(nn)%jcEnd do i = BCData(nn)%icBeg, BCData(nn)%icEnd - rev(1, i, j) = -rev(2, i, j) + call saRoughFact(2, i, j, fact) + rev(1, i, j) = fact * rev(2, i, j) end do end do case (iMax) do j = BCData(nn)%jcBeg, BCData(nn)%jcEnd do i = BCData(nn)%icBeg, BCData(nn)%icEnd - rev(ie, i, j) = -rev(il, i, j) + call saRoughFact(il, i, j, fact) + rev(ie, i, j) = fact * rev(il, i, j) end do end do case (jMin) do j = BCData(nn)%jcBeg, BCData(nn)%jcEnd do i = BCData(nn)%icBeg, BCData(nn)%icEnd - rev(i, 1, j) = -rev(i, 2, j) + call saRoughFact(i, 2, j, fact) + rev(i, 1, j) = fact * rev(i, 2, j) end do end do case (jMax) do j = BCData(nn)%jcBeg, BCData(nn)%jcEnd do i = BCData(nn)%icBeg, BCData(nn)%icEnd - rev(i, je, j) = -rev(i, jl, j) + call saRoughFact(i, jl, j, fact) + rev(i, je, j) = fact * rev(i, jl, j) end do end do case (kMin) do j = BCData(nn)%jcBeg, BCData(nn)%jcEnd do i = BCData(nn)%icBeg, BCData(nn)%icEnd - rev(i, j, 1) = -rev(i, j, 2) + call saRoughFact(i, j, 2, fact) + rev(i, j, 1) = fact * rev(i, j, 2) end do end do case (kMax) do j = BCData(nn)%jcBeg, BCData(nn)%jcEnd do i = BCData(nn)%icBeg, BCData(nn)%icEnd - rev(i, j, ke) = -rev(i, j, kl) + call saRoughFact(i, j, kl, fact) + rev(i, j, ke) = fact * rev(i, j, kl) end do end do end select @@ -819,7 +826,7 @@ subroutine bcTurbWall(nn) ! integer(kind=intType) :: i, j, ii, jj, iiMax, jjMax - real(kind=realType) :: tmpd, tmpe, tmpf, nu + real(kind=realType) :: tmpd, tmpe, tmpf, nu, fact real(kind=realType), dimension(:, :, :, :), pointer :: bmt real(kind=realType), dimension(:, :, :), pointer :: bvt, ww2 @@ -839,39 +846,45 @@ subroutine bcTurbWall(nn) case (iMin) do j = BCData(nn)%jcBeg, BCData(nn)%jcEnd do i = BCData(nn)%icBeg, BCData(nn)%icEnd - bmti1(i, j, itu1, itu1) = one + call saRoughFact(2, i, j, fact) + bmti1(i, j, itu1, itu1) = -fact end do end do case (iMax) do j = BCData(nn)%jcBeg, BCData(nn)%jcEnd do i = BCData(nn)%icBeg, BCData(nn)%icEnd - bmti2(i, j, itu1, itu1) = one + call saRoughFact(il, i, j, fact) + bmti2(i, j, itu1, itu1) = -fact end do end do case (jMin) do j = BCData(nn)%jcBeg, BCData(nn)%jcEnd do i = BCData(nn)%icBeg, BCData(nn)%icEnd - bmtj1(i, j, itu1, itu1) = one + call saRoughFact(i, 2, j, fact) + bmtj1(i, j, itu1, itu1) = -fact end do end do case (jMax) do j = BCData(nn)%jcBeg, BCData(nn)%jcEnd do i = BCData(nn)%icBeg, BCData(nn)%icEnd - bmtj2(i, j, itu1, itu1) = one + call saRoughFact(i, jl, j, fact) + bmtj2(i, j, itu1, itu1) = -fact end do end do case (kMin) do j = BCData(nn)%jcBeg, BCData(nn)%jcEnd do i = BCData(nn)%icBeg, BCData(nn)%icEnd - bmtk1(i, j, itu1, itu1) = one + call saRoughFact(i, j, 2, fact) + bmtk1(i, j, itu1, itu1) = -fact end do end do case (kMax) do j = BCData(nn)%jcBeg, BCData(nn)%jcEnd do i = BCData(nn)%icBeg, BCData(nn)%icEnd - bmtk2(i, j, itu1, itu1) = one + call saRoughFact(i, j, kl, fact) + bmtk2(i, j, itu1, itu1) = -fact end do end do end select @@ -1385,4 +1398,28 @@ subroutine turbBCNSWall(secondHalo) end do bocos end subroutine turbBCNSWall + subroutine saRoughFact(i, j, k, fact) + + ! returns either the regular SA-boundary condition + ! or the modified Roughness-boundary condition + + use constants + use inputPhysics, only: useRoughSA + use BlockPointers, only: ks, d2wall, il, jl, kl + implicit none + + ! local variablse + integer(kind=intType), intent(in) :: i, j, k + real(kind=realType), intent(out) :: fact + + if (.not. useRoughSA) then + fact = -one + return + end if + + fact = (ks(i, j, k) - d2wall(i, j, k) / 0.03_realType) / & + (ks(i, j, k) + d2wall(i, j, k) / 0.03_realType) + + end subroutine saRoughFact + end module turbBCRoutines diff --git a/src/utils/haloExchange.F90 b/src/utils/haloExchange.F90 index 11d9c2665..61a5890ec 100644 --- a/src/utils/haloExchange.F90 +++ b/src/utils/haloExchange.F90 @@ -2639,6 +2639,367 @@ subroutine exchangeCoor(level) end subroutine exchangeCoor + subroutine exchanged2Wall(level) + ! + ! ExchangeCoor exchanges the d2wall of the given grid + ! level. + ! + use block + use communication + use inputTimeSpectral + use utils, only: EChk + implicit none + ! + ! Subroutine arguments. + ! + integer(kind=intType), intent(in) :: level + ! + ! Local variables. + ! + integer :: size, procID, ierr, index + integer, dimension(mpi_status_size) :: mpiStatus + + integer(kind=intType) :: i, j, ii, jj, mm + integer(kind=intType) :: d1, i1, j1, k1, d2, i2, j2, k2 + + ! Loop over the number of spectral solutions. + + spectralLoop: do mm = 1, nTimeIntervalsSpectral + + ! Send the coordinates i have to send. The data is first copied + ! into the send buffer and this buffer is sent. + + ii = 1 + sends: do i = 1, commPatternCell_2nd(level)%nProcSend + + ! Store the processor id and the size of the message + ! a bit easier. + + procID = commPatternCell_2nd(level)%sendProc(i) + size = commPatternCell_2nd(level)%nSend(i) + + ! Copy the data in the correct part of the send buffer. + + jj = ii + !DIR$ NOVECTOR + do j = 1, commPatternCell_2nd(level)%nSend(i) + + ! Store the block id and the indices of the donor + ! a bit easier. + + d1 = commPatternCell_2nd(level)%sendList(i)%block(j) + i1 = commPatternCell_2nd(level)%sendList(i)%indices(j, 1) + j1 = commPatternCell_2nd(level)%sendList(i)%indices(j, 2) + k1 = commPatternCell_2nd(level)%sendList(i)%indices(j, 3) + + ! Copy the coordinates of this point in the buffer. + ! Update the counter jj accordingly. + + sendBuffer(jj) = flowDoms(d1, level, mm)%d2Wall(i1, j1, k1) + jj = jj + 1 + + end do + + ! Send the data. + + call mpi_isend(sendBuffer(ii), size, adflow_real, procID, & + procID, ADflow_comm_world, sendRequests(i), & + ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! Set ii to jj for the next processor. + + ii = jj + + end do sends + + ! Post the nonblocking receives. + + ii = 1 + receives: do i = 1, commPatternCell_2nd(level)%nProcRecv + + ! Store the processor id and the size of the message + ! a bit easier. + + procID = commPatternCell_2nd(level)%recvProc(i) + size = commPatternCell_2nd(level)%nRecv(i) + + ! Post the receive. + + call mpi_irecv(recvBuffer(ii), size, adflow_real, procID, & + myID, ADflow_comm_world, recvRequests(i), ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! And update ii. + + ii = ii + size + + end do receives + + ! Copy the local data. + !DIR$ NOVECTOR + localCopy: do i = 1, internalCell_2nd(level)%nCopy + + ! Store the block and the indices of the donor a bit easier. + + d1 = internalCell_2nd(level)%donorBlock(i) + i1 = internalCell_2nd(level)%donorIndices(i, 1) + j1 = internalCell_2nd(level)%donorIndices(i, 2) + k1 = internalCell_2nd(level)%donorIndices(i, 3) + ! Idem for the halo's. + + d2 = internalCell_2nd(level)%haloBlock(i) + i2 = internalCell_2nd(level)%haloIndices(i, 1) + j2 = internalCell_2nd(level)%haloIndices(i, 2) + k2 = internalCell_2nd(level)%haloIndices(i, 3) + ! Copy the coordinates. + flowDoms(d2, level, mm)%d2Wall(i2, j2, k2) = & + flowDoms(d1, level, mm)%d2Wall(i1, j1, k1) + + end do localCopy + + ! Correct the periodic halos of the internal communication + ! pattern + + ! call correctPeriodicCoor(level, mm, & + ! internalCell_2nd(level)%nPeriodic, & + ! internalCell_2nd(level)%periodicData) + + ! Complete the nonblocking receives in an arbitrary sequence and + ! copy the coordinates from the buffer into the halo's. + + size = commPatternCell_2nd(level)%nProcRecv + completeRecvs: do i = 1, commPatternCell_2nd(level)%nProcRecv + + ! Complete any of the requests. + + call mpi_waitany(size, recvRequests, index, mpiStatus, ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! Copy the data just arrived in the halo's. + + ii = index + jj = commPatternCell_2nd(level)%nRecvCum(ii - 1) + 1 + !DIR$ NOVECTOR + do j = 1, commPatternCell_2nd(level)%nRecv(ii) + + ! Store the block and the indices of the halo a bit easier. + + d2 = commPatternCell_2nd(level)%recvList(ii)%block(j) + i2 = commPatternCell_2nd(level)%recvList(ii)%indices(j, 1) + j2 = commPatternCell_2nd(level)%recvList(ii)%indices(j, 2) + k2 = commPatternCell_2nd(level)%recvList(ii)%indices(j, 3) + + ! Copy the data. + + flowDoms(d2, level, mm)%d2Wall(i2, j2, k2) = recvBuffer(jj) + jj = jj + 1 + + end do + + end do completeRecvs + + ! Correct the periodic halos of the external communication + ! pattern. + + ! call correctPeriodicCoor(level, mm, & + ! commPatternCell_2nd(level)%nPeriodic, & + ! commPatternCell_2nd(level)%periodicData) + + ! Complete the nonblocking sends. + + size = commPatternCell_2nd(level)%nProcSend + do i = 1, commPatternCell_2nd(level)%nProcSend + call mpi_waitany(size, sendRequests, index, mpiStatus, ierr) + call EChk(ierr, __FILE__, __LINE__) + end do + + end do spectralLoop + + end subroutine exchanged2Wall + + + subroutine exchangeKs(level) + ! + ! ExchangeCoor exchanges the wall roughness of the nearest wall of the given grid + ! level. + ! + use block + use communication + use inputTimeSpectral + use utils, only: EChk + implicit none + ! + ! Subroutine arguments. + ! + integer(kind=intType), intent(in) :: level + ! + ! Local variables. + ! + integer :: size, procID, ierr, index + integer, dimension(mpi_status_size) :: mpiStatus + + integer(kind=intType) :: i, j, ii, jj, mm + integer(kind=intType) :: d1, i1, j1, k1, d2, i2, j2, k2 + + ! Loop over the number of spectral solutions. + + spectralLoop: do mm = 1, nTimeIntervalsSpectral + + ! Send the coordinates i have to send. The data is first copied + ! into the send buffer and this buffer is sent. + + ii = 1 + sends: do i = 1, commPatternCell_2nd(level)%nProcSend + + ! Store the processor id and the size of the message + ! a bit easier. + + procID = commPatternCell_2nd(level)%sendProc(i) + size = commPatternCell_2nd(level)%nSend(i) + + ! Copy the data in the correct part of the send buffer. + + jj = ii + !DIR$ NOVECTOR + do j = 1, commPatternCell_2nd(level)%nSend(i) + + ! Store the block id and the indices of the donor + ! a bit easier. + + d1 = commPatternCell_2nd(level)%sendList(i)%block(j) + i1 = commPatternCell_2nd(level)%sendList(i)%indices(j, 1) + j1 = commPatternCell_2nd(level)%sendList(i)%indices(j, 2) + k1 = commPatternCell_2nd(level)%sendList(i)%indices(j, 3) + + ! Copy the coordinates of this point in the buffer. + ! Update the counter jj accordingly. + + sendBuffer(jj) = flowDoms(d1, level, mm)%ks(i1, j1, k1) + jj = jj + 1 + + end do + + ! Send the data. + + call mpi_isend(sendBuffer(ii), size, adflow_real, procID, & + procID, ADflow_comm_world, sendRequests(i), & + ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! Set ii to jj for the next processor. + + ii = jj + + end do sends + + ! Post the nonblocking receives. + + ii = 1 + receives: do i = 1, commPatternCell_2nd(level)%nProcRecv + + ! Store the processor id and the size of the message + ! a bit easier. + + procID = commPatternCell_2nd(level)%recvProc(i) + size = commPatternCell_2nd(level)%nRecv(i) + + ! Post the receive. + + call mpi_irecv(recvBuffer(ii), size, adflow_real, procID, & + myID, ADflow_comm_world, recvRequests(i), ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! And update ii. + + ii = ii + size + + end do receives + + ! Copy the local data. + !DIR$ NOVECTOR + localCopy: do i = 1, internalCell_2nd(level)%nCopy + + ! Store the block and the indices of the donor a bit easier. + + d1 = internalCell_2nd(level)%donorBlock(i) + i1 = internalCell_2nd(level)%donorIndices(i, 1) + j1 = internalCell_2nd(level)%donorIndices(i, 2) + k1 = internalCell_2nd(level)%donorIndices(i, 3) + ! Idem for the halo's. + + d2 = internalCell_2nd(level)%haloBlock(i) + i2 = internalCell_2nd(level)%haloIndices(i, 1) + j2 = internalCell_2nd(level)%haloIndices(i, 2) + k2 = internalCell_2nd(level)%haloIndices(i, 3) + ! Copy the coordinates. + flowDoms(d2, level, mm)%ks(i2, j2, k2) = & + flowDoms(d1, level, mm)%ks(i1, j1, k1) + + end do localCopy + + ! Correct the periodic halos of the internal communication + ! pattern + + ! call correctPeriodicCoor(level, mm, & + ! internalCell_2nd(level)%nPeriodic, & + ! internalCell_2nd(level)%periodicData) + + ! Complete the nonblocking receives in an arbitrary sequence and + ! copy the coordinates from the buffer into the halo's. + + size = commPatternCell_2nd(level)%nProcRecv + completeRecvs: do i = 1, commPatternCell_2nd(level)%nProcRecv + + ! Complete any of the requests. + + call mpi_waitany(size, recvRequests, index, mpiStatus, ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! Copy the data just arrived in the halo's. + + ii = index + jj = commPatternCell_2nd(level)%nRecvCum(ii - 1) + 1 + !DIR$ NOVECTOR + do j = 1, commPatternCell_2nd(level)%nRecv(ii) + + ! Store the block and the indices of the halo a bit easier. + + d2 = commPatternCell_2nd(level)%recvList(ii)%block(j) + i2 = commPatternCell_2nd(level)%recvList(ii)%indices(j, 1) + j2 = commPatternCell_2nd(level)%recvList(ii)%indices(j, 2) + k2 = commPatternCell_2nd(level)%recvList(ii)%indices(j, 3) + + ! Copy the data. + + flowDoms(d2, level, mm)%ks(i2, j2, k2) = recvBuffer(jj) + jj = jj + 1 + + end do + + end do completeRecvs + + ! Correct the periodic halos of the external communication + ! pattern. + + ! call correctPeriodicCoor(level, mm, & + ! commPatternCell_2nd(level)%nPeriodic, & + ! commPatternCell_2nd(level)%periodicData) + + ! Complete the nonblocking sends. + + size = commPatternCell_2nd(level)%nProcSend + do i = 1, commPatternCell_2nd(level)%nProcSend + call mpi_waitany(size, sendRequests, index, mpiStatus, ierr) + call EChk(ierr, __FILE__, __LINE__) + end do + + end do spectralLoop + + + end subroutine exchangeKs + + ! ================================================================== subroutine correctPeriodicCoor(level, sp, nPeriodic, periodicData) @@ -2665,52 +3026,238 @@ subroutine correctPeriodicCoor(level, sp, nPeriodic, periodicData) ! Loop over the number of periodic transformations. - do nn = 1, nPeriodic + do nn = 1, nPeriodic + + ! Store the rotation matrix, rotation center and translation + ! vector a bit easier. + + rotMatrix = periodicData(nn)%rotMatrix + rotCenter = periodicData(nn)%rotCenter + translation = periodicData(nn)%translation + rotCenter + + ! Loop over the number of halo nodes for this transformation. + !DIR$ NOVECTOR + do ii = 1, periodicData(nn)%nHalos + + ! Store the block and the indices a bit easier. + + mm = periodicData(nn)%block(ii) + i = periodicData(nn)%indices(ii, 1) + j = periodicData(nn)%indices(ii, 2) + k = periodicData(nn)%indices(ii, 3) + + ! Determine the vector from the center of rotation to the + ! uncorrected halo value. + + dx = flowDoms(mm, level, sp)%x(i, j, k, 1) - rotCenter(1) + dy = flowDoms(mm, level, sp)%x(i, j, k, 2) - rotCenter(2) + dz = flowDoms(mm, level, sp)%x(i, j, k, 3) - rotCenter(3) + + ! Compute the corrected coordinates. + + flowDoms(mm, level, sp)%x(i, j, k, 1) = rotMatrix(1, 1) * dx & + + rotMatrix(1, 2) * dy & + + rotMatrix(1, 3) * dz & + + translation(1) + flowDoms(mm, level, sp)%x(i, j, k, 2) = rotMatrix(2, 1) * dx & + + rotMatrix(2, 2) * dy & + + rotMatrix(2, 3) * dz & + + translation(2) + flowDoms(mm, level, sp)%x(i, j, k, 3) = rotMatrix(3, 1) * dx & + + rotMatrix(3, 2) * dy & + + rotMatrix(3, 3) * dz & + + translation(3) + end do + end do + + end subroutine correctPeriodicCoor + subroutine exchangeCoor_b(level) + ! + ! ExchangeCoor_b exchanges the *derivatives* of the given grid + ! level IN REVERSE MODE. + ! + use constants + use block + use communication + use inputTimeSpectral + use utils, only: EChk + implicit none + ! + ! Subroutine arguments. + ! + integer(kind=intType), intent(in) :: level + ! + ! Local variables. + ! + integer :: size, procID, ierr, index + integer, dimension(mpi_status_size) :: mpiStatus + + integer(kind=intType) :: i, j, ii, jj, mm, idim + integer(kind=intType) :: d1, i1, j1, k1, d2, i2, j2, k2 + + ! Loop over the number of spectral solutions. + + spectralLoop: do mm = 1, nTimeIntervalsSpectral + + ! Send the coordinates i have to send. The data is first copied + ! into the send buffer and this buffer is sent. + + ii = 1 + jj = 1 + recvs: do i = 1, commPatternNode_1st(level)%nProcRecv + + ! Store the processor id and the size of the message + ! a bit easier. + + procID = commPatternNode_1st(level)%recvProc(i) + size = 3 * commPatternNode_1st(level)%nRecv(i) + + ! Copy the data in the correct part of the send buffer. + !DIR$ NOVECTOR + do j = 1, commPatternNode_1st(level)%nRecv(i) + + ! Store the block id and the indices of the donor + ! a bit easier. + + d1 = commPatternNode_1st(level)%recvList(i)%block(j) + i1 = commPatternNode_1st(level)%recvList(i)%indices(j, 1) + j1 = commPatternNode_1st(level)%recvList(i)%indices(j, 2) + k1 = commPatternNode_1st(level)%recvList(i)%indices(j, 3) + + ! Copy the coordinates of this point in the buffer. + ! Update the counter jj accordingly. + + recvBuffer(jj) = flowDomsd(d1, level, mm)%x(i1, j1, k1, 1) + recvBuffer(jj + 1) = flowDomsd(d1, level, mm)%x(i1, j1, k1, 2) + recvBuffer(jj + 2) = flowDomsd(d1, level, mm)%x(i1, j1, k1, 3) + jj = jj + 3 + flowDomsd(d1, level, mm)%x(i1, j1, k1, :) = zero + end do + + ! Send the data. + + call mpi_isend(recvBuffer(ii), size, adflow_real, procID, & + procID, ADflow_comm_world, recvRequests(i), & + ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! Set ii to jj for the next processor. + + ii = jj + + end do recvs + + ! Post the nonblocking receives. + + ii = 1 + send: do i = 1, commPatternNode_1st(level)%nProcSend + + ! Store the processor id and the size of the message + ! a bit easier. + + procID = commPatternNode_1st(level)%sendProc(i) + size = 3 * commPatternNode_1st(level)%nSend(i) + + ! Post the receive. + + call mpi_irecv(sendBuffer(ii), size, adflow_real, procID, & + myID, ADflow_comm_world, sendRequests(i), ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! And update ii. + + ii = ii + size + + end do send + + ! Copy the local data. + !DIR$ NOVECTOR + localCopy: do i = 1, internalNode_1st(level)%nCopy + + ! Store the block and the indices of the donor a bit easier. + + d1 = internalNode_1st(level)%donorBlock(i) + i1 = internalNode_1st(level)%donorIndices(i, 1) + j1 = internalNode_1st(level)%donorIndices(i, 2) + k1 = internalNode_1st(level)%donorIndices(i, 3) + ! Idem for the halo's. + + d2 = internalNode_1st(level)%haloBlock(i) + i2 = internalNode_1st(level)%haloIndices(i, 1) + j2 = internalNode_1st(level)%haloIndices(i, 2) + k2 = internalNode_1st(level)%haloIndices(i, 3) + + ! Sum into the '1' values fro the '2' values + do idim = 1, 3 + flowDomsd(d1, level, mm)%x(i1, j1, k1, idim) = flowDomsd(d1, level, mm)%x(i1, j1, k1, idim) + & + flowDomsd(d2, level, mm)%x(i2, j2, k2, idim) + flowDomsd(d2, level, mm)%x(i2, j2, k2, idim) = zero + end do + end do localCopy + + ! Correct the periodic halos of the internal communication + ! pattern + + ! NOT IMPLEMENTED + ! call correctPeriodicCoor(level, mm, & + ! internalNode_1st(level)%nPeriodic, & + ! internalNode_1st(level)%periodicData) + + ! Complete the nonblocking receives in an arbitrary sequence and + ! copy the coordinates from the buffer into the halo's. + + size = commPatternNode_1st(level)%nProcSend + completeSends: do i = 1, commPatternNode_1st(level)%nProcSend + + ! Complete any of the requests. + + call mpi_waitany(size, sendRequests, index, mpiStatus, ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! Copy the data just arrived in the halo's. - ! Store the rotation matrix, rotation center and translation - ! vector a bit easier. + ii = index + jj = 3 * commPatternNode_1st(level)%nSendCum(ii - 1) + !DIR$ NOVECTOR + do j = 1, commPatternNode_1st(level)%nSend(ii) - rotMatrix = periodicData(nn)%rotMatrix - rotCenter = periodicData(nn)%rotCenter - translation = periodicData(nn)%translation + rotCenter + ! Store the block and the indices of the halo a bit easier. - ! Loop over the number of halo nodes for this transformation. - !DIR$ NOVECTOR - do ii = 1, periodicData(nn)%nHalos + d2 = commPatternNode_1st(level)%sendList(ii)%block(j) + i2 = commPatternNode_1st(level)%sendList(ii)%indices(j, 1) + j2 = commPatternNode_1st(level)%sendList(ii)%indices(j, 2) + k2 = commPatternNode_1st(level)%sendList(ii)%indices(j, 3) - ! Store the block and the indices a bit easier. + ! Sum into the '2' values from the recv buffer + do idim = 1, 3 + flowDomsd(d2, level, mm)%x(i2, j2, k2, idim) = flowDomsd(d2, level, mm)%x(i2, j2, k2, idim) + & + sendBuffer(jj + idim) + end do + jj = jj + 3 - mm = periodicData(nn)%block(ii) - i = periodicData(nn)%indices(ii, 1) - j = periodicData(nn)%indices(ii, 2) - k = periodicData(nn)%indices(ii, 3) + end do - ! Determine the vector from the center of rotation to the - ! uncorrected halo value. + end do completeSends - dx = flowDoms(mm, level, sp)%x(i, j, k, 1) - rotCenter(1) - dy = flowDoms(mm, level, sp)%x(i, j, k, 2) - rotCenter(2) - dz = flowDoms(mm, level, sp)%x(i, j, k, 3) - rotCenter(3) + ! Correct the periodic halos of the external communication + ! pattern. + ! NOT IMLEMENTED + ! call correctPeriodicCoor(level, mm, & + ! commPatternNode_1st(level)%nPeriodic, & + ! commPatternNode_1st(level)%periodicData) - ! Compute the corrected coordinates. + ! Complete the nonblocking sends. - flowDoms(mm, level, sp)%x(i, j, k, 1) = rotMatrix(1, 1) * dx & - + rotMatrix(1, 2) * dy & - + rotMatrix(1, 3) * dz & - + translation(1) - flowDoms(mm, level, sp)%x(i, j, k, 2) = rotMatrix(2, 1) * dx & - + rotMatrix(2, 2) * dy & - + rotMatrix(2, 3) * dz & - + translation(2) - flowDoms(mm, level, sp)%x(i, j, k, 3) = rotMatrix(3, 1) * dx & - + rotMatrix(3, 2) * dy & - + rotMatrix(3, 3) * dz & - + translation(3) + size = commPatternNode_1st(level)%nProcRecv + do i = 1, commPatternNode_1st(level)%nProcRecv + call mpi_waitany(size, recvRequests, index, mpiStatus, ierr) + call EChk(ierr, __FILE__, __LINE__) end do - end do - end subroutine correctPeriodicCoor - subroutine exchangeCoor_b(level) + end do spectralLoop + + end subroutine exchangeCoor_b + subroutine exchanged2Wall_b(level) ! ! ExchangeCoor_b exchanges the *derivatives* of the given grid ! level IN REVERSE MODE. @@ -2743,34 +3290,32 @@ subroutine exchangeCoor_b(level) ii = 1 jj = 1 - recvs: do i = 1, commPatternNode_1st(level)%nProcRecv + recvs: do i = 1, commPatternCell_2nd(level)%nProcRecv ! Store the processor id and the size of the message ! a bit easier. - procID = commPatternNode_1st(level)%recvProc(i) - size = 3 * commPatternNode_1st(level)%nRecv(i) + procID = commPatternCell_2nd(level)%recvProc(i) + size = commPatternCell_2nd(level)%nRecv(i) ! Copy the data in the correct part of the send buffer. !DIR$ NOVECTOR - do j = 1, commPatternNode_1st(level)%nRecv(i) + do j = 1, commPatternCell_2nd(level)%nRecv(i) ! Store the block id and the indices of the donor ! a bit easier. - d1 = commPatternNode_1st(level)%recvList(i)%block(j) - i1 = commPatternNode_1st(level)%recvList(i)%indices(j, 1) - j1 = commPatternNode_1st(level)%recvList(i)%indices(j, 2) - k1 = commPatternNode_1st(level)%recvList(i)%indices(j, 3) + d2 = commPatternCell_2nd(level)%recvList(i)%block(j) + i2 = commPatternCell_2nd(level)%recvList(i)%indices(j, 1) + j2 = commPatternCell_2nd(level)%recvList(i)%indices(j, 2) + k2 = commPatternCell_2nd(level)%recvList(i)%indices(j, 3) ! Copy the coordinates of this point in the buffer. ! Update the counter jj accordingly. - recvBuffer(jj) = flowDomsd(d1, level, mm)%x(i1, j1, k1, 1) - recvBuffer(jj + 1) = flowDomsd(d1, level, mm)%x(i1, j1, k1, 2) - recvBuffer(jj + 2) = flowDomsd(d1, level, mm)%x(i1, j1, k1, 3) - jj = jj + 3 - flowDomsd(d1, level, mm)%x(i1, j1, k1, :) = zero + recvBuffer(jj) = flowDomsd(d2, level, mm)%d2Wall(i2, j2, k2) + flowDomsd(d2, level, mm)%d2Wall(i2, j2, k2) = zero + jj = jj + 1 end do ! Send the data. @@ -2789,13 +3334,13 @@ subroutine exchangeCoor_b(level) ! Post the nonblocking receives. ii = 1 - send: do i = 1, commPatternNode_1st(level)%nProcSend + send: do i = 1, commPatternCell_2nd(level)%nProcSend ! Store the processor id and the size of the message ! a bit easier. - procID = commPatternNode_1st(level)%sendProc(i) - size = 3 * commPatternNode_1st(level)%nSend(i) + procID = commPatternCell_2nd(level)%sendProc(i) + size = commPatternCell_2nd(level)%nSend(i) ! Post the receive. @@ -2811,27 +3356,27 @@ subroutine exchangeCoor_b(level) ! Copy the local data. !DIR$ NOVECTOR - localCopy: do i = 1, internalNode_1st(level)%nCopy + localCopy: do i = 1, internalCell_2nd(level)%nCopy ! Store the block and the indices of the donor a bit easier. - d1 = internalNode_1st(level)%donorBlock(i) - i1 = internalNode_1st(level)%donorIndices(i, 1) - j1 = internalNode_1st(level)%donorIndices(i, 2) - k1 = internalNode_1st(level)%donorIndices(i, 3) + d1 = internalCell_2nd(level)%donorBlock(i) + i1 = internalCell_2nd(level)%donorIndices(i, 1) + j1 = internalCell_2nd(level)%donorIndices(i, 2) + k1 = internalCell_2nd(level)%donorIndices(i, 3) + ! Idem for the halo's. - d2 = internalNode_1st(level)%haloBlock(i) - i2 = internalNode_1st(level)%haloIndices(i, 1) - j2 = internalNode_1st(level)%haloIndices(i, 2) - k2 = internalNode_1st(level)%haloIndices(i, 3) + d2 = internalCell_2nd(level)%haloBlock(i) + i2 = internalCell_2nd(level)%haloIndices(i, 1) + j2 = internalCell_2nd(level)%haloIndices(i, 2) + k2 = internalCell_2nd(level)%haloIndices(i, 3) ! Sum into the '1' values fro the '2' values - do idim = 1, 3 - flowDomsd(d1, level, mm)%x(i1, j1, k1, idim) = flowDomsd(d1, level, mm)%x(i1, j1, k1, idim) + & - flowDomsd(d2, level, mm)%x(i2, j2, k2, idim) - flowDomsd(d2, level, mm)%x(i2, j2, k2, idim) = zero - end do + flowDomsd(d1, level, mm)%d2Wall(i1, j1, k1) = flowDomsd(d1, level, mm)%d2Wall(i1, j1, k1) + & + flowDomsd(d2, level, mm)%d2Wall(i2, j2, k2) + flowDomsd(d2, level, mm)%d2Wall(i2, j2, k2) = zero + end do localCopy ! Correct the periodic halos of the internal communication @@ -2845,8 +3390,8 @@ subroutine exchangeCoor_b(level) ! Complete the nonblocking receives in an arbitrary sequence and ! copy the coordinates from the buffer into the halo's. - size = commPatternNode_1st(level)%nProcSend - completeSends: do i = 1, commPatternNode_1st(level)%nProcSend + size = commPatternCell_2nd(level)%nProcSend + completeSends: do i = 1, commPatternCell_2nd(level)%nProcSend ! Complete any of the requests. @@ -2856,23 +3401,21 @@ subroutine exchangeCoor_b(level) ! Copy the data just arrived in the halo's. ii = index - jj = 3 * commPatternNode_1st(level)%nSendCum(ii - 1) + jj = commPatternCell_2nd(level)%nSendCum(ii - 1) !DIR$ NOVECTOR - do j = 1, commPatternNode_1st(level)%nSend(ii) + do j = 1, commPatternCell_2nd(level)%nSend(ii) ! Store the block and the indices of the halo a bit easier. - d2 = commPatternNode_1st(level)%sendList(ii)%block(j) - i2 = commPatternNode_1st(level)%sendList(ii)%indices(j, 1) - j2 = commPatternNode_1st(level)%sendList(ii)%indices(j, 2) - k2 = commPatternNode_1st(level)%sendList(ii)%indices(j, 3) + d2 = commPatternCell_2nd(level)%sendList(ii)%block(j) + i2 = commPatternCell_2nd(level)%sendList(ii)%indices(j, 1) + j2 = commPatternCell_2nd(level)%sendList(ii)%indices(j, 2) + k2 = commPatternCell_2nd(level)%sendList(ii)%indices(j, 3) ! Sum into the '2' values from the recv buffer - do idim = 1, 3 - flowDomsd(d2, level, mm)%x(i2, j2, k2, idim) = flowDomsd(d2, level, mm)%x(i2, j2, k2, idim) + & - sendBuffer(jj + idim) - end do - jj = jj + 3 + jj = jj + 1 + flowDomsd(d2, level, mm)%d2Wall(i2, j2, k2) = flowDomsd(d2, level, mm)%d2Wall(i2, j2, k2) + & + sendBuffer(jj) end do @@ -2887,15 +3430,15 @@ subroutine exchangeCoor_b(level) ! Complete the nonblocking sends. - size = commPatternNode_1st(level)%nProcRecv - do i = 1, commPatternNode_1st(level)%nProcRecv + size = commPatternCell_2nd(level)%nProcRecv + do i = 1, commPatternCell_2nd(level)%nProcRecv call mpi_waitany(size, recvRequests, index, mpiStatus, ierr) call EChk(ierr, __FILE__, __LINE__) end do end do spectralLoop - end subroutine exchangeCoor_b + end subroutine exchanged2Wall_b subroutine exchangeCoor_d(level) ! ! ExchangeCoor_d exchanges the *derivatives* of the given grid @@ -3083,6 +3626,185 @@ subroutine exchangeCoor_d(level) end do spectralLoop end subroutine exchangeCoor_d + subroutine exchanged2Wall_d(level) + ! + ! ExchangeCoor_d exchanges the *derivatives* of the given grid + ! level. + ! + use block + use communication + use inputTimeSpectral + use utils, only: EChk + implicit none + ! + ! Subroutine arguments. + ! + integer(kind=intType), intent(in) :: level + ! + ! Local variables. + ! + integer :: size, procID, ierr, index + integer, dimension(mpi_status_size) :: mpiStatus + + integer(kind=intType) :: i, j, ii, jj, mm + integer(kind=intType) :: d1, i1, j1, k1, d2, i2, j2, k2 + + ! Loop over the number of spectral solutions. + + spectralLoop: do mm = 1, nTimeIntervalsSpectral + + ! Send the coordinates i have to send. The data is first copied + ! into the send buffer and this buffer is sent. + + ii = 1 + sends: do i = 1, commPatternCell_2nd(level)%nProcSend + + ! Store the processor id and the size of the message + ! a bit easier. + + procID = commPatternCell_2nd(level)%sendProc(i) + size = commPatternCell_2nd(level)%nSend(i) + + ! Copy the data in the correct part of the send buffer. + + jj = ii + !DIR$ NOVECTOR + do j = 1, commPatternCell_2nd(level)%nSend(i) + + ! Store the block id and the indices of the donor + ! a bit easier. + + d1 = commPatternCell_2nd(level)%sendList(i)%block(j) + i1 = commPatternCell_2nd(level)%sendList(i)%indices(j, 1) + j1 = commPatternCell_2nd(level)%sendList(i)%indices(j, 2) + k1 = commPatternCell_2nd(level)%sendList(i)%indices(j, 3) + + ! Copy the coordinates of this point in the buffer. + ! Update the counter jj accordingly. + + sendBuffer(jj) = flowDomsd(d1, level, mm)%d2Wall(i1, j1, k1) + jj = jj + 1 + + end do + + ! Send the data. + + call mpi_isend(sendBuffer(ii), size, adflow_real, procID, & + procID, ADflow_comm_world, sendRequests(i), & + ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! Set ii to jj for the next processor. + + ii = jj + + end do sends + + ! Post the nonblocking receives. + + ii = 1 + receives: do i = 1, commPatternCell_2nd(level)%nProcRecv + + ! Store the processor id and the size of the message + ! a bit easier. + + procID = commPatternCell_2nd(level)%recvProc(i) + size = commPatternCell_2nd(level)%nRecv(i) + + ! Post the receive. + + call mpi_irecv(recvBuffer(ii), size, adflow_real, procID, & + myID, ADflow_comm_world, recvRequests(i), ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! And update ii. + + ii = ii + size + + end do receives + + ! Copy the local data. + !DIR$ NOVECTOR + localCopy: do i = 1, internalCell_2nd(level)%nCopy + + ! Store the block and the indices of the donor a bit easier. + + d1 = internalCell_2nd(level)%donorBlock(i) + i1 = internalCell_2nd(level)%donorIndices(i, 1) + j1 = internalCell_2nd(level)%donorIndices(i, 2) + k1 = internalCell_2nd(level)%donorIndices(i, 3) + ! Idem for the halo's. + + d2 = internalCell_2nd(level)%haloBlock(i) + i2 = internalCell_2nd(level)%haloIndices(i, 1) + j2 = internalCell_2nd(level)%haloIndices(i, 2) + k2 = internalCell_2nd(level)%haloIndices(i, 3) + ! Copy the coordinates. + flowDomsd(d2, level, mm)%d2Wall(i2, j2, k2) = & + flowDomsd(d1, level, mm)%d2Wall(i1, j1, k1) + + end do localCopy + + ! Correct the periodic halos of the internal communication + ! pattern + + ! NOT IMPLEMENTED + ! call correctPeriodicCoor(level, mm, & + ! internalCell_2nd(level)%nPeriodic, & + ! internalCell_2nd(level)%periodicData) + + ! Complete the nonblocking receives in an arbitrary sequence and + ! copy the coordinates from the buffer into the halo's. + + size = commPatternCell_2nd(level)%nProcRecv + completeRecvs: do i = 1, commPatternCell_2nd(level)%nProcRecv + + ! Complete any of the requests. + + call mpi_waitany(size, recvRequests, index, mpiStatus, ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! Copy the data just arrived in the halo's. + + ii = index + jj = commPatternCell_2nd(level)%nRecvCum(ii - 1) + 1 + !DIR$ NOVECTOR + do j = 1, commPatternCell_2nd(level)%nRecv(ii) + + ! Store the block and the indices of the halo a bit easier. + + d2 = commPatternCell_2nd(level)%recvList(ii)%block(j) + i2 = commPatternCell_2nd(level)%recvList(ii)%indices(j, 1) + j2 = commPatternCell_2nd(level)%recvList(ii)%indices(j, 2) + k2 = commPatternCell_2nd(level)%recvList(ii)%indices(j, 3) + + ! Copy the data. + + flowDomsd(d2, level, mm)%d2Wall(i2, j2, k2) = recvBuffer(jj) + jj = jj + 1 + + end do + + end do completeRecvs + + ! Correct the periodic halos of the external communication + ! pattern. + ! NOT IMLEMENTED + ! call correctPeriodicCoor(level, mm, & + ! commPatternCell_2nd(level)%nPeriodic, & + ! commPatternCell_2nd(level)%periodicData) + + ! Complete the nonblocking sends. + + size = commPatternCell_2nd(level)%nProcSend + do i = 1, commPatternCell_2nd(level)%nProcSend + call mpi_waitany(size, sendRequests, index, mpiStatus, ierr) + call EChk(ierr, __FILE__, __LINE__) + end do + + end do spectralLoop + + end subroutine exchanged2Wall_d ! ----------------------------------------------------------------- ! Comm routines for zippers diff --git a/src/utils/utils.F90 b/src/utils/utils.F90 index b50cc8c17..a9a8b5a78 100644 --- a/src/utils/utils.F90 +++ b/src/utils/utils.F90 @@ -888,12 +888,14 @@ subroutine setBCPointers(nn, spatialPointers) use blockPointers, only: w, p, rlv, rev, gamma, x, d2wall, & si, sj, sk, s, globalCell, BCData, nx, il, ie, ib, & ny, jl, je, jb, nz, kl, ke, kb, BCFaceID, & - addgridvelocities, sFaceI, sFaceJ, sFaceK, addGridVelocities + addgridvelocities, sFaceI, sFaceJ, sFaceK, addGridVelocities, & + d2wall, ks use BCPointers, only: ww0, ww1, ww2, ww3, pp0, pp1, pp2, pp3, & rlv0, rlv1, rlv2, rlv3, rev0, rev1, rev2, rev3, & gamma0, gamma1, gamma2, gamma3, gcp, xx, ss, ssi, ssj, ssk, dd2wall, & - sFace, iStart, iEnd, jStart, jEnd, iSize, jSize - use inputPhysics, only: cpModel, equations + sFace, iStart, iEnd, jStart, jEnd, iSize, jSize, & + d2wall0, d2wall1, d2wall2, d2wall3, ks0, ks1, ks2, ks3 + use inputPhysics, only: cpModel, equations, useRoughSA implicit none ! Subroutine arguments. @@ -939,6 +941,18 @@ subroutine setBCPointers(nn, spatialPointers) rev1 => rev(1, 1:, 1:) rev0 => rev(0, 1:, 1:) + d2wall3 => d2wall(3, 1:, 1:) + d2wall2 => d2wall(2, 1:, 1:) + d2wall1 => d2wall(1, 1:, 1:) + d2wall0 => d2wall(0, 1:, 1:) + + if (useRoughSA) then + ks3 => ks(3, 1:, 1:) + ks2 => ks(2, 1:, 1:) + ks1 => ks(1, 1:, 1:) + ks0 => ks(0, 1:, 1:) + end if + gamma3 => gamma(3, 1:, 1:) gamma2 => gamma(2, 1:, 1:) gamma1 => gamma(1, 1:, 1:) @@ -969,6 +983,18 @@ subroutine setBCPointers(nn, spatialPointers) rev1 => rev(ie, 1:, 1:) rev0 => rev(ib, 1:, 1:) + d2wall3 => d2wall(nx, 1:, 1:) + d2wall2 => d2wall(il, 1:, 1:) + d2wall1 => d2wall(ie, 1:, 1:) + d2wall0 => d2wall(ib, 1:, 1:) + + if (useRoughSA) then + ks3 => ks(nx, 1:, 1:) + ks2 => ks(il, 1:, 1:) + ks1 => ks(ie, 1:, 1:) + ks0 => ks(ib, 1:, 1:) + end if + gamma3 => gamma(nx, 1:, 1:) gamma2 => gamma(il, 1:, 1:) gamma1 => gamma(ie, 1:, 1:) @@ -999,6 +1025,18 @@ subroutine setBCPointers(nn, spatialPointers) rev1 => rev(1:, 1, 1:) rev0 => rev(1:, 0, 1:) + d2wall3 => d2wall(1:, 3, 1:) + d2wall2 => d2wall(1:, 2, 1:) + d2wall1 => d2wall(1:, 1, 1:) + d2wall0 => d2wall(1:, 0, 1:) + + if (useRoughSA) then + ks3 => ks(1:, 3, 1:) + ks2 => ks(1:, 2, 1:) + ks1 => ks(1:, 1, 1:) + ks0 => ks(1:, 0, 1:) + end if + gamma3 => gamma(1:, 3, 1:) gamma2 => gamma(1:, 2, 1:) gamma1 => gamma(1:, 1, 1:) @@ -1029,6 +1067,18 @@ subroutine setBCPointers(nn, spatialPointers) rev1 => rev(1:, je, 1:) rev0 => rev(1:, jb, 1:) + d2wall3 => d2wall(1:, ny, 1:) + d2wall2 => d2wall(1:, jl, 1:) + d2wall1 => d2wall(1:, je, 1:) + d2wall0 => d2wall(1:, jb, 1:) + + if (useRoughSA) then + ks3 => ks(1:, ny, 1:) + ks2 => ks(1:, jl, 1:) + ks1 => ks(1:, je, 1:) + ks0 => ks(1:, jb, 1:) + end if + gamma3 => gamma(1:, ny, 1:) gamma2 => gamma(1:, jl, 1:) gamma1 => gamma(1:, je, 1:) @@ -1059,6 +1109,18 @@ subroutine setBCPointers(nn, spatialPointers) rev1 => rev(1:, 1:, 1) rev0 => rev(1:, 1:, 0) + d2wall3 => d2wall(1:, 1:, 3) + d2wall2 => d2wall(1:, 1:, 2) + d2wall1 => d2wall(1:, 1:, 1) + d2wall0 => d2wall(1:, 1:, 0) + + if (useRoughSA) then + ks3 => ks(1:, 1:, 3) + ks2 => ks(1:, 1:, 2) + ks1 => ks(1:, 1:, 1) + ks0 => ks(1:, 1:, 0) + end if + gamma3 => gamma(1:, 1:, 3) gamma2 => gamma(1:, 1:, 2) gamma1 => gamma(1:, 1:, 1) @@ -1089,6 +1151,18 @@ subroutine setBCPointers(nn, spatialPointers) rev1 => rev(1:, 1:, ke) rev0 => rev(1:, 1:, kb) + d2wall3 => d2wall(1:, 1:, nz) + d2wall2 => d2wall(1:, 1:, kl) + d2wall1 => d2wall(1:, 1:, ke) + d2wall0 => d2wall(1:, 1:, kb) + + if (useRoughSA) then + ks3 => ks(1:, 1:, nz) + ks2 => ks(1:, 1:, kl) + ks1 => ks(1:, 1:, ke) + ks0 => ks(1:, 1:, kb) + end if + gamma3 => gamma(1:, 1:, nz) gamma2 => gamma(1:, 1:, kl) gamma1 => gamma(1:, 1:, ke) @@ -2056,14 +2130,16 @@ subroutine setbcpointers_d(nn, spatialpointers) & gamma, x, xd, d2wall, d2walld, si, sid, sj, sjd, sk, skd, s, sd, & & globalcell, bcdata, bcdatad, nx, il, ie, ib, ny, jl, je, jb, nz, kl,& & ke, kb, bcfaceid, addgridvelocities, sfacei, sfaceid, sfacej, & - & sfacejd, sfacek, sfacekd, addgridvelocities + & sfacejd, sfacek, sfacekd, addgridvelocities, d2wall, d2walld, ks use bcpointers_d, only: ww0, ww0d, ww1, ww1d, ww2, ww2d, ww3, ww3d,& & pp0, pp0d, pp1, pp1d, pp2, pp2d, pp3, pp3d, rlv0, rlv0d, rlv1, rlv1d& & , rlv2, rlv2d, rlv3, rlv3d, rev0, rev0d, rev1, rev1d, rev2, rev2d, & & rev3, rev3d, gamma0, gamma1, gamma2, gamma3, gcp, xx, xxd, ss, ssd, & & ssi, ssid, ssj, ssjd, ssk, sskd, dd2wall, sface, istart, iend, & - & jstart, jend, isize, jsize - use inputphysics, only: cpmodel, equations + & jstart, jend, isize, jsize, & + d2wall0, d2wall0d, d2wall1, d2wall1d, d2wall2, d2wall2d, d2wall3, d2wall3d, & + ks0, ks1, ks2, ks3 + use inputphysics, only: cpmodel, equations, useRoughSA implicit none ! subroutine arguments. integer(kind=inttype), intent(in) :: nn @@ -2114,11 +2190,25 @@ subroutine setbcpointers_d(nn, spatialpointers) rev1 => rev(1, 1:, 1:) rev0d => revd(0, 1:, 1:) rev0 => rev(0, 1:, 1:) + d2wall3d => d2walld(3, 1:, 1:) + d2wall3 => d2wall(3, 1:, 1:) + d2wall2d => d2walld(2, 1:, 1:) + d2wall2 => d2wall(2, 1:, 1:) + d2wall1d => d2walld(1, 1:, 1:) + d2wall1 => d2wall(1, 1:, 1:) + d2wall0d => d2walld(0, 1:, 1:) + d2wall0 => d2wall(0, 1:, 1:) gamma3 => gamma(3, 1:, 1:) gamma2 => gamma(2, 1:, 1:) gamma1 => gamma(1, 1:, 1:) gamma0 => gamma(0, 1:, 1:) gcp => globalcell(2, 1:, 1:) + if (useRoughSA) then + ks3 => ks(3, 1:, 1:) + ks2 => ks(2, 1:, 1:) + ks1 => ks(1, 1:, 1:) + ks0 => ks(0, 1:, 1:) + end if case (imax) !--------------------------------------------------------------------------- ww3d => wd(nx, 1:, 1:, :) @@ -2153,11 +2243,25 @@ subroutine setbcpointers_d(nn, spatialpointers) rev1 => rev(ie, 1:, 1:) rev0d => revd(ib, 1:, 1:) rev0 => rev(ib, 1:, 1:) + d2wall3d => d2walld(nx, 1:, 1:) + d2wall3 => d2wall(nx, 1:, 1:) + d2wall2d => d2walld(il, 1:, 1:) + d2wall2 => d2wall(il, 1:, 1:) + d2wall1d => d2walld(ie, 1:, 1:) + d2wall1 => d2wall(ie, 1:, 1:) + d2wall0d => d2walld(ib, 1:, 1:) + d2wall0 => d2wall(ib, 1:, 1:) gamma3 => gamma(nx, 1:, 1:) gamma2 => gamma(il, 1:, 1:) gamma1 => gamma(ie, 1:, 1:) gamma0 => gamma(ib, 1:, 1:) gcp => globalcell(il, 1:, 1:) + if (useRoughSA) then + ks3 => ks(nx, 1:, 1:) + ks2 => ks(il, 1:, 1:) + ks1 => ks(ie, 1:, 1:) + ks0 => ks(ib, 1:, 1:) + end if case (jmin) !--------------------------------------------------------------------------- ww3d => wd(1:, 3, 1:, :) @@ -2192,11 +2296,25 @@ subroutine setbcpointers_d(nn, spatialpointers) rev1 => rev(1:, 1, 1:) rev0d => revd(1:, 0, 1:) rev0 => rev(1:, 0, 1:) + d2wall3d => d2walld(1:, 3, 1:) + d2wall3 => d2wall(1:, 3, 1:) + d2wall2d => d2walld(1:, 2, 1:) + d2wall2 => d2wall(1:, 2, 1:) + d2wall1d => d2walld(1:, 1, 1:) + d2wall1 => d2wall(1:, 1, 1:) + d2wall0d => d2walld(1:, 0, 1:) + d2wall0 => d2wall(1:, 0, 1:) gamma3 => gamma(1:, 3, 1:) gamma2 => gamma(1:, 2, 1:) gamma1 => gamma(1:, 1, 1:) gamma0 => gamma(1:, 0, 1:) gcp => globalcell(1:, 2, 1:) + if (useRoughSA) then + ks3 => ks(1:, 3, 1:) + ks2 => ks(1:, 2, 1:) + ks1 => ks(1:, 1, 1:) + ks0 => ks(1:, 0, 1:) + end if case (jmax) !--------------------------------------------------------------------------- ww3d => wd(1:, ny, 1:, :) @@ -2231,11 +2349,25 @@ subroutine setbcpointers_d(nn, spatialpointers) rev1 => rev(1:, je, 1:) rev0d => revd(1:, jb, 1:) rev0 => rev(1:, jb, 1:) + d2wall3d => d2walld(1:, ny, 1:) + d2wall3 => d2wall(1:, ny, 1:) + d2wall2d => d2walld(1:, jl, 1:) + d2wall2 => d2wall(1:, jl, 1:) + d2wall1d => d2walld(1:, je, 1:) + d2wall1 => d2wall(1:, je, 1:) + d2wall0d => d2walld(1:, jb, 1:) + d2wall0 => d2wall(1:, jb, 1:) gamma3 => gamma(1:, ny, 1:) gamma2 => gamma(1:, jl, 1:) gamma1 => gamma(1:, je, 1:) gamma0 => gamma(1:, jb, 1:) gcp => globalcell(1:, jl, 1:) + if (useRoughSA) then + ks3 => ks(1:, ny, 1:) + ks2 => ks(1:, jl, 1:) + ks1 => ks(1:, je, 1:) + ks0 => ks(1:, jb, 1:) + end if case (kmin) !--------------------------------------------------------------------------- ww3d => wd(1:, 1:, 3, :) @@ -2270,11 +2402,25 @@ subroutine setbcpointers_d(nn, spatialpointers) rev1 => rev(1:, 1:, 1) rev0d => revd(1:, 1:, 0) rev0 => rev(1:, 1:, 0) + d2wall3d => d2walld(1:, 1:, 3) + d2wall3 => d2wall(1:, 1:, 3) + d2wall2d => d2walld(1:, 1:, 2) + d2wall2 => d2wall(1:, 1:, 2) + d2wall1d => d2walld(1:, 1:, 1) + d2wall1 => d2wall(1:, 1:, 1) + d2wall0d => d2walld(1:, 1:, 0) + d2wall0 => d2wall(1:, 1:, 0) gamma3 => gamma(1:, 1:, 3) gamma2 => gamma(1:, 1:, 2) gamma1 => gamma(1:, 1:, 1) gamma0 => gamma(1:, 1:, 0) gcp => globalcell(1:, 1:, 2) + if (useRoughSA) then + ks3 => ks(1:, 1:, 3) + ks2 => ks(1:, 1:, 2) + ks1 => ks(1:, 1:, 1) + ks0 => ks(1:, 1:, 0) + end if case (kmax) !--------------------------------------------------------------------------- ww3d => wd(1:, 1:, nz, :) @@ -2309,11 +2455,25 @@ subroutine setbcpointers_d(nn, spatialpointers) rev1 => rev(1:, 1:, ke) rev0d => revd(1:, 1:, kb) rev0 => rev(1:, 1:, kb) + d2wall3d => d2walld(1:, 1:, nz) + d2wall3 => d2wall(1:, 1:, nz) + d2wall2d => d2walld(1:, 1:, kl) + d2wall2 => d2wall(1:, 1:, kl) + d2wall1d => d2walld(1:, 1:, ke) + d2wall1 => d2wall(1:, 1:, ke) + d2wall0d => d2walld(1:, 1:, kb) + d2wall0 => d2wall(1:, 1:, kb) gamma3 => gamma(1:, 1:, nz) gamma2 => gamma(1:, 1:, kl) gamma1 => gamma(1:, 1:, ke) gamma0 => gamma(1:, 1:, kb) gcp => globalcell(1:, 1:, kl) + if (useRoughSA) then + ks3 => ks(1:, 1:, nz) + ks2 => ks(1:, 1:, kl) + ks1 => ks(1:, 1:, ke) + ks0 => ks(1:, 1:, kb) + end if end select if (spatialpointers) then select case (bcfaceid(nn)) @@ -3242,6 +3402,7 @@ subroutine setPointers(nn, mm, ll) ! from blockPointers so use a bare use. use constants use blockPointers + use inputPhysics, only: useRoughSA implicit none ! ! Subroutine arguments @@ -3480,6 +3641,9 @@ subroutine setPointers(nn, mm, ll) d2Wall => flowDoms(nn, mm, ll)%d2Wall filterDES => flowDoms(nn, mm, ll)%filterDES ! eran-des + if (useRoughSA) then + ks => flowDoms(nn, mm, ll)%ks + end if ! Arrays used for the implicit treatment of the turbulent wall ! boundary conditions. As these variables are only allocated for @@ -4600,7 +4764,7 @@ subroutine deallocDerivativeValues(level) use inputtimespectral, only: nTimeIntervalsSpectral use wallDistanceData, only: xSurfVec, xSurfVecd use flowVarRefState, only: winfd - use inputPhysics, only: wallDistanceNeeded + use inputPhysics, only: wallDistanceNeeded, useRoughSA use adjointVars, only: derivVarsAllocated use BCPointers_b @@ -4917,6 +5081,10 @@ subroutine deallocateBlock(nn, level, sps) deallocate (BCData(i)%TNS_Wall, stat=ierr) if (ierr /= 0) deallocationFailure = .true. + if (associated(BCData(i)%ksNS_Wall)) & + deallocate (BCData(i)%ksNS_Wall, stat=ierr) + if (ierr /= 0) deallocationFailure = .true. + if (associated(BCData(i)%ptInlet)) & deallocate (BCData(i)%ptInlet, stat=ierr) if (ierr /= 0) deallocationFailure = .true. @@ -4996,6 +5164,7 @@ subroutine deallocateBlock(nn, level, sps) nullify (BCData(i)%uSlip) nullify (BCData(i)%TNS_Wall) + nullify (BCData(i)%ksNS_Wall) nullify (BCData(i)%normALE) nullify (BCData(i)%rfaceALE) diff --git a/src/wallDistance/wallDistance.F90 b/src/wallDistance/wallDistance.F90 index 105cd5e6d..1a9845a4d 100644 --- a/src/wallDistance/wallDistance.F90 +++ b/src/wallDistance/wallDistance.F90 @@ -126,6 +126,216 @@ end subroutine updateWallDistancesQuickly ! ---------------------------------------------------------------------- #ifndef USE_TAPENADE + + subroutine updateWallRoughness() + + ! Sets the roughness-value (ks) of the nearest wall-cell in the volume cells. + ! + ! At first, it creates two lists: (1) ks values on the surface; (2) global + ! cellIndex corresponding to this ks-value. + ! + ! Then it gathers the full list on each proc *THIS DOES NOT SCALE IN MEMORY* + ! + ! After that, it iterate through every volume cell and finds the index in + ! list (1) that corresponds to the cellIndex of the nearest surface-cell. + ! Then it uses this index to set the ks value listed in (2). + ! + ! + ! A more memory efficient approach would be to create a 'PETSc Scatter'. + ! This should be straight forward using the cellIndex-list mentioned above. + ! You might take a look at 'wallScatter' further down this file for + ! inspiration. + + use constants + use blockPointers + use inputTimeSpectral, only: nTimeIntervalsSpectral + use inputPhysics, only: useRoughSA + use utils, only: setPointers, EChk, terminate + use surfaceFamilies, only: BCFamGroups + use communication, only: adflow_comm_world, nProc, myID + use sorting, only: famInList + use wallDistanceData, only: nCellBlockOffset + use haloExchange, only : exchangeKs + implicit none + + ! Local Variables + integer(kind=intType) :: i, j, k, ii, jj, ierr, iCell + integer(kind=intType) :: iBeg, jBeg, iEnd, jEnd, ni, nj + integer(kind=intType) :: nn, sps, level, nLevels, mm + integer(kind=intType), dimension(:), allocatable :: nCellProc, cumCellProc + integer(kind=intType), dimension(:), pointer :: wallFamList + integer(kind=intType), dimension(:), allocatable :: cellIdLocal, cellIdGlobal + integer(kind=intType) :: nCellsLocal, nCellsGlobal + real(kind=realType), dimension(:), allocatable :: ksLocal, ksGlobal + + character(len=maxStringLen) :: errorMessage + + ! exit if not in use + if (.not. useRoughSA) then + return + end if + + wallFamList => BCFamGroups(iBCGroupWalls)%famList + nLevels = ubound(flowDoms, 2) + + do level = 1, nLevels + do sps = 1, nTimeIntervalsSpectral + + ! figure out the local space needed + nCellsLocal = 0 + do nn = 1, nDom + call setPointers(nn, level, sps) + + do mm = 1, nBocos + if (.not. famInList(BCdata(mm)%famID, wallFamlist)) then + cycle + end if + nCellsLocal = nCellsLocal + & + (bcData(mm)%inEnd - bcData(mm)%inBeg) * (bcData(mm)%jnEnd - bcData(mm)%jnBeg) + end do + end do + + ! Now communicate these sizes with everyone + allocate (nCellProc(nProc), cumCellProc(0:nProc)) + + call mpi_allgather(nCellsLocal, 1, adflow_integer, nCellProc, 1, adflow_integer, & + adflow_comm_world, ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! Now make cumulative versions of these + cumCellProc(0) = 0 + do i = 1, nProc + cumCellProc(i) = cumCellProc(i - 1) + nCellProc(i) + end do + + ! And save the total number of nodes and cells for reference + nCellsGlobal = cumCellProc(nProc) + + ! Allocate the space for the local ks values and cellId's + allocate (ksLocal(nCellsLocal), cellIdLocal(nCellsLocal)) + + ! Move all the local ks-values in a list + ! Create a second list with the global cell ID corresponding to the ks-values + iCell = 0 + do nn = 1, nDom + call setPointers(nn, level, sps) + do mm = 1, nBocos + if (.not. famInList(BCdata(mm)%famID, wallFamlist)) then + cycle + end if + + jBeg = BCData(mm)%jnBeg; jEnd = BCData(mm)%jnEnd + iBeg = BCData(mm)%inBeg; iEnd = BCData(mm)%inEnd + ni = iEnd - iBeg + nj = jEnd - jBeg + + do jj = 1, nj + do ii = 1, ni + iCell = iCell + 1 + + ! saving local ks-value is easy + ksLocal(iCell) = BCData(mm)%ksNS_Wall(ii, jj) + + ! to calculate the global cellID, we must associate the + ! BC-cell to the volume cell first. We basically have to + ! set surface i-j values to global i,j,k values. + + select case (BCFaceID(mm)) + case (iMin) + i = 2 + j = ii + 1 + k = jj + 1 + case (iMax) + i = il + j = ii + 1 + k = jj + 1 + case (jMin) + i = ii + 1 + j = 2 + k = jj + 1 + case (jMax) + i = ii + 1 + j = jl + k = jj + 1 + case (kMin) + i = ii + 1 + j = jj + 1 + k = 2 + case (kMax) + i = ii + 1 + j = jj + 1 + k = kl + end select + + cellIdLocal(iCell) = nCellBLockOffset(level, nn) * nTimeIntervalsSpectral + & + nx * ny * nz * (sps - 1) + (i - 2) + (j - 2) * nx + & + (k - 2) * nx * ny + end do + end do + end do + end do + + ! allocate global arrays + allocate (ksGlobal(nCellsGlobal), cellIdGlobal(nCellsGlobal)) + + ! gather all the surface-ks values on each proc + call mpi_allgatherv(ksLocal, nCellsLocal, adflow_real, & + ksGlobal, nCellProc, cumCellProc, adflow_real, & + adflow_comm_world, ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! gather all the cellId's on each proc + call mpi_allgatherv(cellIdLocal, nCellsLocal, adflow_integer, & + cellIdGlobal, nCellProc, cumCellProc, adflow_integer, & + adflow_comm_world, ierr) + call EChk(ierr, __FILE__, __LINE__) + + ! free local memory + deallocate (cumCellProc, nCellProc, ksLocal, cellIdLocal) + + ! set the ks-values in the volume + do nn = 1, nDom + call setPointers(nn, level, sps) + do k = 2, kl + do j = 2, jl + do i = 2, il + if (flowDoms(nn, level, sps)%nearestWallCellInd(i, j, k) == -1) then + ! This cell is too far away and has no + ! association. Set the roughness to zero. + ks(i, j, k) = zero + cycle + end if + + ! find the index of the surface cell (Requires gfortran > 9.0 ) + iCell = findloc( & + cellIdGlobal, & + flowDoms(nn, level, sps)%nearestWallCellInd(i, j, k), & + DIM = 1) + + if (iCell == 0) then + write (errorMessage, 100) & + flowDoms(nn, level, sps)%nearestWallCellInd(i, j, k) +100 format("Could not find surface cell with id ", I10.1) + call terminate("updateWallRoughness", errorMessage) + end if + + ! set the ks value + ks(i, j, k) = ksGlobal(iCell) + end do + end do + end do + end do + + ! free global memory + deallocate (ksGlobal, cellIdGlobal) + end do + end do + + + call exchangeKs(1) + + end subroutine updateWallRoughness + subroutine computeWallDistance(level, allocMem) ! ! wallDistance computes the distances of the cell centers to @@ -474,6 +684,7 @@ subroutine initWallDistance(level, sps, allocMem) ! use constants use blockPointers, only: nDom, flowDoms + use inputPhysics, only: useRoughSA use utils, only: terminate implicit none ! @@ -486,7 +697,7 @@ subroutine initWallDistance(level, sps, allocMem) ! integer :: ierr - integer(kind=intType) :: nn, il, jl, kl + integer(kind=intType) :: nn, ib, jb, kb ! Loop over the domains. @@ -496,15 +707,26 @@ subroutine initWallDistance(level, sps, allocMem) if (allocMem) then - il = flowDoms(nn, level, sps)%il - jl = flowDoms(nn, level, sps)%jl - kl = flowDoms(nn, level, sps)%kl + ib = flowDoms(nn, level, sps)%ib + jb = flowDoms(nn, level, sps)%jb + kb = flowDoms(nn, level, sps)%kb - allocate (flowDoms(nn, level, sps)%d2Wall(2:il, 2:jl, 2:kl), & + allocate (flowDoms(nn, level, sps)%d2Wall(0:ib, 0:jb, 0:kb), & stat=ierr) if (ierr /= 0) & call terminate("initWallDistance", & "Memory allocation failure for d2Wall") + + if (useRoughSA) then + allocate (flowDoms(nn, level, sps)%ks(0:ib, 0:jb, 0:kb), & + stat=ierr) + if (ierr /= 0) & + call terminate("initWallDistance", & + "Memory allocation failure for ks") + + ! initalize to zero + flowDoms(nn, level, sps)%ks = zero + end if end if ! Initialize the wall distances to a large value. @@ -1531,6 +1753,8 @@ subroutine updateWallDistanceAllLevels use block, only: flowDoms use inputPhysics, only: equations use iteration, only: groundLevel + use haloExchange, only: exchanged2Wall + use inputPhysics, only: wallDistanceNeeded implicit none ! ! Local variables. @@ -1546,6 +1770,9 @@ subroutine updateWallDistanceAllLevels nLevels = ubound(flowDoms, 2) do nn = groundLevel, nLevels call computeWallDistance(nn, .false.) + if (wallDistanceNeeded) then + call exchanged2Wall(nn) + end if end do end subroutine updateWallDistanceAllLevels @@ -1737,6 +1964,10 @@ subroutine determineWallAssociation(level, sps) allocate (fullWall%conn(4, nCells)) allocate (fullWall%ind(nNodes)) + if (useRoughSA) then + allocate (fullWall%indCell(nCells)) + end if + nNodes = 0 nCells = 0 ii = 0 @@ -1753,6 +1984,9 @@ subroutine determineWallAssociation(level, sps) do j = 1, walls(i)%nCells nCells = nCells + 1 fullWall%conn(:, nCells) = walls(i)%conn(:, j) + ii + if (useRoughSA) then + fullWall%indCell(nCells) = walls(i)%indCell(j) + end if end do ! Increment the node offset @@ -1781,6 +2015,9 @@ subroutine determineWallAssociation(level, sps) if (.not. associated(flowDoms(nn, level, sps)%surfNodeIndices)) then allocate (flowDoms(nn, level, sps)%surfNodeIndices(4, 2:il, 2:jl, 2:kl)) allocate (flowDoms(nn, level, sps)%uv(2, 2:il, 2:jl, 2:kl)) + if (useRoughSA) then + allocate (flowDoms(nn, level, sps)%nearestWallCellInd(2:il, 2:jl, 2:kl)) + end if end if ! Set the cluster for this block @@ -1823,10 +2060,16 @@ subroutine determineWallAssociation(level, sps) walls(c)%ind(walls(c)%conn(kk, cellID)) end do flowDoms(nn, level, sps)%uv(:, i, j, k) = uvw(1:2) + if (useRoughSA) then + flowDoms(nn, level, sps)%nearestWallCellInd(i, j, k) = walls(c)%indCell(cellID) + end if else ! Just set dummy values. These will never be used. flowDoms(nn, level, sps)%surfNodeIndices(:, i, j, k) = 0 flowDoms(nn, level, sps)%uv(:, i, j, k) = 0 + if (useRoughSA) then + flowDoms(nn, level, sps)%nearestWallCellInd(i, j, k) = -1 + end if end if ! We are done with this point. @@ -1856,7 +2099,9 @@ subroutine determineWallAssociation(level, sps) fullWall%ind(fullWall%conn(kk, cellID)) end do flowDoms(nn, level, sps)%uv(:, i, j, k) = uvw(1:2) - + if (useRoughSA) then + flowDoms(nn, level, sps)%nearestWallCellInd(i, j, k) = fullWall%indCell(cellID) + end if else ! This point is *closer* than the nearWallDist AND @@ -1876,6 +2121,9 @@ subroutine determineWallAssociation(level, sps) walls(c)%ind(walls(c)%conn(kk, cellID2)) end do flowDoms(nn, level, sps)%uv(:, i, j, k) = uvw2(1:2) + if (useRoughSA) then + flowDoms(nn, level, sps)%nearestWallCellInd(i, j, k) = fullWall%indCell(cellID2) + end if else ! The full wall distance is better. Take that. @@ -1884,7 +2132,9 @@ subroutine determineWallAssociation(level, sps) fullWall%ind(fullWall%conn(kk, cellID)) end do flowDoms(nn, level, sps)%uv(:, i, j, k) = uvw(1:2) - + if (useRoughSA) then + flowDoms(nn, level, sps)%nearestWallCellInd(i, j, k) = fullWall%indCell(cellID) + end if end if end if else @@ -1895,7 +2145,9 @@ subroutine determineWallAssociation(level, sps) flowDoms(nn, level, sps)%surfNodeIndices(:, i, j, k) = 0 flowDoms(nn, level, sps)%uv(:, i, j, k) = 0 - + if (useRoughSA) then + flowDoms(nn, level, sps)%nearestWallCellInd(i, j, k) = -1 + end if end if end do end do diff --git a/tests/reg_tests/refs/adjoint_rans_rough_sa.json b/tests/reg_tests/refs/adjoint_rans_rough_sa.json new file mode 100644 index 000000000..11a894b86 --- /dev/null +++ b/tests/reg_tests/refs/adjoint_rans_rough_sa.json @@ -0,0 +1,824 @@ +{ + "Eval Functions Sens:": { + "mdo_tutorial_cd": { + "P_mdo_tutorial": 1.1906967920303641e-08, + "T_mdo_tutorial": 5.7032101376918994e-08, + "alpha_mdo_tutorial": 0.005064588210334737, + "beta_mdo_tutorial": -0.0008845056168120727, + "mach_mdo_tutorial": 0.09103183719324591, + "shape": { + "__ndarray__": [ + [ + 0.0014588561633413414, + -0.00014952202413208286, + -0.015675497912023488, + -0.014075987294571204, + 0.0013475090668360465, + 0.0018275783162532001, + -0.012563970825243631, + -0.010466961719321863, + 0.001309403504721567, + -0.003255740658843033, + 0.0022778281149183153, + 0.006688705333327987, + -0.0018114416783712132, + 0.005977863590813565, + 0.00983532858473589, + 0.007136309610539732, + 0.0005148684493146728, + -0.0019678518803612076, + 0.002182198480909613, + 0.004428502895915052, + 0.004347966506713412, + 0.0036422607708835367, + 0.003191112901777175, + 0.004015687155590336, + 0.002041987254186593, + 0.00216664730487107, + 0.0019894942777849856, + 0.0016303801990091183, + -0.019657992669769538, + -0.020829881820670266, + -0.02078458749231964, + -0.018884803905128002, + -0.0003694888783061555, + -0.0003130644455712657, + -0.0003057568816089407, + 0.0002687965388743136, + -0.017918307322412758, + -0.018865739227695775, + -0.018591839838973466, + -0.016488737753057772, + 0.0009126579204761291, + 0.0008121165240817337, + 0.0008901093226245515, + 0.0010405934847586217, + -0.004064662192245191, + -0.0037963248994502177, + -0.0032041778422513857, + -0.002629339527700363, + 0.0033331749562904543, + 0.0034921467579424295, + 0.003357522945849655, + 0.0030107497004535763, + 0.007440267908310526, + 0.007319659848397562, + 0.006915771850659987, + 0.00616224817217152, + 0.0004202215889943551, + 0.003131548800067598, + 0.005383622398366069, + 0.0068249401797487366, + 0.01037563525198086, + 0.011987962339168481, + 0.011950338215280503, + 0.009432492888063287, + 0.011250802433469834, + 0.009854871187475862, + 0.008009282452942326, + 0.005465380393532938, + 0.00617765891204428, + 0.005047041663475567, + 0.004344579308030662, + 0.004048996264051067 + ] + ], + "dtype": "float64", + "shape": [ + 1, + 72 + ] + }, + "span": 0.00229664892833175, + "twist": { + "__ndarray__": [ + [ + -0.0009085025652585955, + -0.0011352774844096654, + -0.001113026381374366, + -0.0009513310772895932, + -0.0006868004819044367, + -0.0003151052366628259 + ] + ], + "dtype": "float64", + "shape": [ + 1, + 6 + ] + }, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "mdo_tutorial_cl": { + "P_mdo_tutorial": -2.2527598084617437e-07, + "T_mdo_tutorial": -1.3233798184113253e-07, + "alpha_mdo_tutorial": 0.11733097471392283, + "beta_mdo_tutorial": -0.005417244776871343, + "mach_mdo_tutorial": 0.44617528313282584, + "shape": { + "__ndarray__": [ + [ + 0.0006642837325210593, + -0.009763975859965732, + -0.3801481999887656, + -0.3170998426235122, + 0.012629573615866977, + 0.02315397958563808, + -0.19944009087270742, + -0.1691912552790567, + 0.0351498387083226, + 0.06625716321778724, + 0.09120797369196265, + 0.15959099100025592, + 0.07840389483505791, + 0.06061702563900386, + 0.0471183163334587, + 0.1618610610277068, + 0.027871493172952767, + 0.03253649812508121, + 0.04177297503503383, + 0.05856781186588396, + 0.0313022523470325, + 0.02349066959756217, + 0.04666961628569403, + 0.07533994488661211, + 0.008047029629268385, + 0.013538816921931512, + 0.01504317535187119, + 0.01571547469209155, + -0.46385021365505386, + -0.4739910307711922, + -0.44823629888730077, + -0.3689000683369753, + 0.008718298792151594, + 0.029550012094386215, + 0.043126338752077574, + 0.04434158317192526, + -0.3956395141009607, + -0.4079461176825463, + -0.3862046757086361, + -0.3163656910038524, + 0.06398787247549687, + 0.07479431304247744, + 0.07286149409348636, + 0.05846138573422667, + 0.08736651118290667, + 0.08697245700465966, + 0.0800864819250691, + 0.06426740266179096, + 0.10936456656828654, + 0.10829983086081271, + 0.10157510658835196, + 0.08255237277265481, + 0.174394811331467, + 0.16923186958607747, + 0.15458484011444382, + 0.1203484559615018, + 0.11961152090585189, + 0.12724633074407918, + 0.11338965533117872, + 0.07770697893018691, + 0.05670971831375479, + 0.03836441180009568, + 0.024469827398488818, + 0.019976171681793435, + 0.04934729534821406, + 0.05111766067208243, + 0.056306951989697436, + 0.060501561915658614, + 0.18336415728743627, + 0.1839642086404485, + 0.172950832038159, + 0.14031382776067444 + ] + ], + "dtype": "float64", + "shape": [ + 1, + 72 + ] + }, + "span": 0.04345766409999452, + "twist": { + "__ndarray__": [ + [ + -0.024654336084479405, + -0.028750831788918046, + -0.025904206045517835, + -0.020158455062478375, + -0.012724745076232755, + -0.004816128687393934 + ] + ], + "dtype": "float64", + "shape": [ + 1, + 6 + ] + }, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "mdo_tutorial_cmz": { + "P_mdo_tutorial": -3.656206038639332e-07, + "T_mdo_tutorial": -2.3220688985427506e-07, + "alpha_mdo_tutorial": 0.15587229388605317, + "beta_mdo_tutorial": -0.009601346793082532, + "mach_mdo_tutorial": 0.8704444540175915, + "shape": { + "__ndarray__": [ + [ + -0.029047420922817188, + -0.04708038357322772, + -0.49032488213844316, + -0.4013165545103022, + 0.009544996586770077, + 0.026725344461077258, + -0.44647176923194504, + -0.3753146224937229, + 0.01782744019989366, + 0.08962447709312292, + 0.13469816620993494, + 0.2308823656803091, + 0.06582854869951546, + 0.07763779529085339, + 0.09150764410109205, + 0.2507771488956023, + 0.05119051469137706, + 0.07611290577460351, + 0.10139817895149289, + 0.14288701914486024, + 0.05984782406821292, + 0.060871228049129186, + 0.11793992001578524, + 0.18543399479046915, + -0.0357932204896516, + -0.02906455119109569, + -0.01801481334783786, + -0.0024114995232683567, + -0.6512116044666574, + -0.7548564706156609, + -0.8101131292991757, + -0.7525335106763098, + -0.044525501572274084, + -0.017099525064875748, + 0.01681056318887561, + 0.041434083335101235, + -0.545809688007461, + -0.640587162239928, + -0.6906120551468395, + -0.6398075609220193, + 0.054791469450099516, + 0.08331789087620665, + 0.09984195609069375, + 0.09540815288288124, + 0.1306150031496364, + 0.14676641870076226, + 0.15217947592334216, + 0.13677505061708325, + 0.17617158370280409, + 0.1955737376811594, + 0.20395944236578603, + 0.18339267529484207, + 0.2786572043773582, + 0.3033890890341621, + 0.30782564735585616, + 0.26624818061430483, + 0.12544638422745383, + 0.1608101384189547, + 0.1687095486591529, + 0.13384106597714177, + 0.08919774441517907, + 0.07838533748537196, + 0.06617923921964464, + 0.06122622884183163, + 0.11227959483655524, + 0.1280157086416137, + 0.1452414371823498, + 0.15534712133864104, + 0.3110117072275599, + 0.34532456199659967, + 0.3561773650682832, + 0.31731939747434174 + ] + ], + "dtype": "float64", + "shape": [ + 1, + 72 + ] + }, + "span": 0.06413597231156332, + "twist": { + "__ndarray__": [ + [ + -0.02496719304046418, + -0.03216019106103158, + -0.03408737451797081, + -0.03126987441866044, + -0.02296784989696189, + -0.009658514402793021 + ] + ], + "dtype": "float64", + "shape": [ + 1, + 6 + ] + }, + "xRef_mdo_tutorial": -0.12640436393489274, + "yRef_mdo_tutorial": 0.0035902070779581328, + "zRef_mdo_tutorial": 0.0 + }, + "mdo_tutorial_drag": { + "P_mdo_tutorial": 0.5056157462992771, + "T_mdo_tutorial": 0.023250847089342996, + "alpha_mdo_tutorial": 2064.731321589265, + "beta_mdo_tutorial": -360.59524986194486, + "mach_mdo_tutorial": 62149.935067818835, + "shape": { + "__ndarray__": [ + [ + 594.7464806710151, + -60.95713879814559, + -6390.586988773744, + -5738.498500250781, + 549.3524963677182, + 745.067127970098, + -5122.079626035299, + -4267.170953733126, + 533.8176208049622, + -1327.3003517970392, + 928.624965889924, + 2726.851390291158, + -738.4885434383391, + 2437.055428702888, + 4009.6667574251287, + 2909.330702024834, + 209.90156941660013, + -802.2538545856731, + 889.6386766972295, + 1805.4120606066551, + 1772.5789854569516, + 1484.8768710738282, + 1300.952907796529, + 1637.1153395910706, + 832.4773637868072, + 883.298773249864, + 811.077027167412, + 664.6733995320438, + -8014.1704516117015, + -8491.92622065088, + -8473.460628868917, + -7698.956856042612, + -150.63322590781638, + -127.63011317048972, + -124.65096549433201, + 109.58297296828539, + -7304.935529201246, + -7691.184568347064, + -7579.521265552777, + -6722.1286071665745, + 372.07238101978254, + 331.0836645378183, + 362.8797686476965, + 424.22915186639136, + -1657.0814825344248, + -1547.6857350076039, + -1306.279222728841, + -1071.9291386528516, + 1358.8687661805395, + 1423.6783902780644, + 1368.7949545640595, + 1227.4224378809442, + 3033.248420860041, + 2984.0789269947195, + 2819.421868077051, + 2512.225334830884, + 171.315937401259, + 1276.6698148115597, + 2194.795179365885, + 2782.3916124800135, + 4229.93897952753, + 4887.252486432245, + 4871.91388360555, + 3845.438700605667, + 4586.72713607695, + 4017.633885710158, + 3265.2242704154896, + 2228.1262788355048, + 2518.507985262193, + 2057.5779453657105, + 1771.1980922979335, + 1650.6947969283333 + ] + ], + "dtype": "float64", + "shape": [ + 1, + 72 + ] + }, + "span": 936.2978351023139, + "twist": { + "__ndarray__": [ + [ + -370.378325804621, + -462.8299248441359, + -453.758595158707, + -387.83865358942626, + -279.9948204628006, + -128.4621028827006 + ] + ], + "dtype": "float64", + "shape": [ + 1, + 6 + ] + }, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "mdo_tutorial_lift": { + "P_mdo_tutorial": 8.270592846885688, + "T_mdo_tutorial": -0.053951548436925734, + "alpha_mdo_tutorial": 47833.491771372086, + "beta_mdo_tutorial": -2208.5023506349153, + "mach_mdo_tutorial": 600018.4073654441, + "shape": { + "__ndarray__": [ + [ + 270.81519207461315, + -3980.5776785900707, + -154978.81817142142, + -129275.2638407544, + 5148.8245717165655, + 9439.414397472698, + -81307.73624698544, + -68975.89095216605, + 14329.886244609828, + 27011.72030062839, + 37183.66671473962, + 65062.05521098424, + 31963.699846357027, + 24712.349012509727, + 19209.195202824365, + 65987.51735977479, + 11362.650336749326, + 13264.479555633185, + 17030.006462282712, + 23876.925541483586, + 12761.302236837797, + 9576.676181534183, + 19026.26916735209, + 30714.588731374057, + 3280.6130392607665, + 5519.504882733236, + 6132.801727450802, + 6406.884722471794, + -189102.45510289547, + -193236.6634248001, + -182736.9743303752, + -150393.17985961973, + 3554.2760515851987, + 12046.94893063933, + 17581.74578244701, + 18077.176627530247, + -161294.31710868227, + -166311.47325681994, + -157447.92219289733, + -128975.96490845073, + 26086.575850811285, + 30492.145541157413, + 29704.17391203255, + 23833.53773612961, + 35617.57927904792, + 35456.931271659865, + 32649.656951211997, + 26200.53471715887, + 44585.74649855906, + 44151.67504533622, + 41410.1394539392, + 33654.95133195592, + 71097.27668361232, + 68992.44859285219, + 63021.147617856484, + 49063.65852638495, + 48763.224842896896, + 51875.78411774403, + 46226.694685412665, + 31679.581170257843, + 23119.417962151383, + 15640.40340266184, + 9975.859233811978, + 8143.885671231952, + 20117.905367559186, + 20839.647902794906, + 22955.2181871585, + 24665.276761774807, + 74753.89964294108, + 74998.52857853827, + 70508.59520531689, + 57203.14130147164 + ] + ], + "dtype": "float64", + "shape": [ + 1, + 72 + ] + }, + "span": 17716.820500284084, + "twist": { + "__ndarray__": [ + [ + -10051.079734920826, + -11721.139103706326, + -10560.626720636898, + -8218.19895987124, + -5187.624072678598, + -1963.439343276776 + ] + ], + "dtype": "float64", + "shape": [ + 1, + 6 + ] + }, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + } + }, + "Norm of residual": 3.237191827215383e-14, + "metadata": { + "ADPC": false, + "ANKADPC": false, + "ANKAMGLevels": 2, + "ANKAMGNSmooth": 1, + "ANKASMOverlap": 1, + "ANKASMOverlapCoarse": 0, + "ANKCFL0": 5.0, + "ANKCFLCutback": 0.5, + "ANKCFLExponent": 0.5, + "ANKCFLFactor": 10.0, + "ANKCFLLimit": 100000.0, + "ANKCFLMin": 1.0, + "ANKCFLReset": true, + "ANKCharTimeStepType": "None", + "ANKConstCFLStep": 0.4, + "ANKCoupledSwitchTol": 1e-16, + "ANKGlobalPreconditioner": "additive Schwarz", + "ANKInnerPreconIts": 1, + "ANKInnerPreconItsCoarse": 1, + "ANKJacobianLag": 10, + "ANKLinResMax": 0.1, + "ANKLinearSolveBuffer": 0.01, + "ANKLinearSolveTol": 0.05, + "ANKMaxIter": 40, + "ANKNSubiterTurb": 1, + "ANKOuterPreconIts": 1, + "ANKPCILUFill": 2, + "ANKPCILUFillCoarse": 0, + "ANKPCUpdateCutoff": 1e-16, + "ANKPCUpdateTol": 0.5, + "ANKPCUpdateTolAfterCutoff": 0.0001, + "ANKPhysicalLSTol": 0.2, + "ANKPhysicalLSTolTurb": 0.99, + "ANKSecondOrdSwitchTol": 0.01, + "ANKStepFactor": 1.0, + "ANKStepMin": 0.01, + "ANKSubspaceSize": -1, + "ANKSwitchTol": 0.01, + "ANKTurbCFLScale": 1.0, + "ANKTurbKSPDebug": false, + "ANKUnsteadyLSTol": 1.0, + "ANKUseApproxSA": false, + "ANKUseFullVisc": true, + "ANKUseMatrixFree": true, + "ANKUseTurbDADI": true, + "ASMOverlap": 1, + "ASMOverlapCoarse": 0, + "CFL": 1.5, + "CFLCoarse": 1.25, + "CFLLimit": 1.5, + "GMRESOrthogonalizationType": "modified Gram-Schmidt", + "ILUFill": 2, + "ILUFillCoarse": 0, + "L2Convergence": 1e-15, + "L2ConvergenceCoarse": 0.01, + "L2ConvergenceRel": 1e-16, + "MGCycle": "2w", + "MGStartLevel": -1, + "NKADPC": false, + "NKAMGLevels": 2, + "NKAMGNSmooth": 1, + "NKASMOverlap": 1, + "NKASMOverlapCoarse": 0, + "NKFixedStep": 0.25, + "NKGlobalPreconditioner": "additive Schwarz", + "NKInnerPreconIts": 1, + "NKInnerPreconItsCoarse": 1, + "NKJacobianLag": 2, + "NKLS": "cubic", + "NKLinearSolveTol": 1e-06, + "NKOuterPreconIts": 1, + "NKPCILUFill": 2, + "NKPCILUFillCoarse": 0, + "NKSubspaceSize": 60, + "NKSwitchTol": 1e-05, + "NKUseEW": false, + "NKViscPC": false, + "RKReset": false, + "TSStability": false, + "acousticScaleFactor": 1.0, + "adjointAMGLevels": 2, + "adjointAMGNSmooth": 1, + "adjointDivTol": 100000.0, + "adjointL2Convergence": 1e-16, + "adjointL2ConvergenceAbs": 1e-16, + "adjointL2ConvergenceRel": 1e-16, + "adjointMaxIter": 500, + "adjointMaxL2DeviationFactor": 1.0, + "adjointMonitorStep": 10, + "adjointSolver": "GMRES", + "adjointSubspaceSize": 100, + "alphaFollowing": true, + "alphaMode": false, + "altitudeMode": false, + "applyAdjointPCSubspaceSize": 20, + "applyPCSubspaceSize": 10, + "approxPC": true, + "backgroundVolScale": 1.0, + "betaMode": false, + "blockSplitting": true, + "cavExponent": 0, + "cavSensorOffset": 0.0, + "cavSensorSharpness": 10.0, + "cavitationNumber": 1.4, + "closedSurfaceFamilies": null, + "coarseDiscretization": "central plus scalar dissipation", + "computeCavitation": false, + "coupledSolution": false, + "cpMinRho": 100.0, + "cutCallback": null, + "debugZipper": false, + "deltaT": 0.01, + "designSurfaceFamily": null, + "discretization": "central plus scalar dissipation", + "dissContMagnitude": 1.0, + "dissContMidpoint": 3.0, + "dissContSharpness": 3.0, + "dissipationLumpingParameter": 6.0, + "dissipationScalingExponent": 0.67, + "eddyVisInfRatio": 0.009, + "equationMode": "steady", + "equationType": "RANS", + "eulerWallTreatment": "linear pressure extrapolation", + "explicitSurfaceCallback": null, + "firstRun": true, + "flowType": "external", + "forcesAsTractions": true, + "frozenTurbulence": false, + "globalPreconditioner": "additive Schwarz", + "gridFile": "input_files/mdo_tutorial_rough.cgns", + "gridPrecision": "double", + "gridPrecisionSurface": "single", + "infChangeCorrection": true, + "infChangeCorrectionTol": 1e-12, + "infChangeCorrectionType": "offset", + "innerPreconIts": 1, + "innerPreconItsCoarse": 1, + "isoVariables": [], + "isosurface": {}, + "liftIndex": 2, + "limiter": "van Albada", + "loadBalanceIter": 10, + "loadImbalance": 0.1, + "localPreconditioner": "ILU", + "lowSpeedPreconditioner": false, + "machMode": false, + "matrixOrdering": "RCM", + "maxL2DeviationFactor": 1.0, + "meshMaxSkewness": 1.0, + "meshSurfaceFamily": null, + "monitorVariables": [ + "resrho", + "resturb", + "cd" + ], + "nCycles": 1000, + "nCyclesCoarse": 100, + "nFloodIter": -1, + "nRKReset": 5, + "nRefine": 10, + "nSaveSurface": 1, + "nSaveVolume": 1, + "nSubiter": 3, + "nSubiterTurb": 3, + "nTimeStepsCoarse": 48, + "nTimeStepsFine": 400, + "nearWallDist": 0.1, + "numberSolutions": true, + "outerPreconIts": 3, + "outputDirectory": "tests/output_files", + "outputSurfaceFamily": "allSurfaces", + "overlapFactor": 0.9, + "oversetDebugPrint": false, + "oversetLoadBalance": true, + "oversetPriority": {}, + "oversetProjTol": 1e-12, + "oversetUpdateMode": "frozen", + "pMode": false, + "partitionLikeNProc": -1, + "partitionOnly": false, + "preconditionerSide": "right", + "printAllOptions": true, + "printBadlySkewedCells": false, + "printIntro": true, + "printIterations": true, + "printNegativeVolumes": false, + "printTiming": true, + "printWarnings": true, + "qMode": false, + "rMode": false, + "recomputeOverlapMatrix": true, + "resAveraging": "never", + "restartAdjoint": true, + "restartFile": "input_files/mdo_tutorial_rough.cgns", + "restrictionRelaxation": 0.8, + "selfZipCutoff": 120.0, + "sepSensorOffset": 0.0, + "sepSensorSharpness": 10.0, + "setMonitor": true, + "skipAfterFailedAdjoint": true, + "smoothParameter": 1.5, + "smoother": "DADI", + "solutionPrecision": "single", + "solutionPrecisionSurface": "single", + "storeConvHist": true, + "storeRindLayer": true, + "surfaceVariables": [ + "cp", + "vx", + "vy", + "vz", + "mach" + ], + "timeAccuracy": 2, + "timeIntegrationScheme": "BDF", + "timeIntervals": 1, + "timeLimit": -1.0, + "turbResScale": 10000.0, + "turbulenceModel": "SA", + "turbulenceOrder": "first order", + "turbulenceProduction": "strain", + "updateWallAssociations": false, + "useALE": true, + "useANKSolver": true, + "useApproxWallDistance": true, + "useBlockettes": false, + "useDiagTSPC": true, + "useDissContinuation": false, + "useExternalDynamicMesh": false, + "useGridMotion": false, + "useLinResMonitor": false, + "useMatrixFreedrdw": true, + "useNKSolver": true, + "useOversetWallScaling": false, + "useQCR": false, + "useRotationSA": false, + "useRoughSA": true, + "useSkewnessCheck": false, + "useTSInterpolatedGridVelocity": false, + "useWallFunctions": false, + "useZipperMesh": true, + "useft2SA": true, + "verifyExtra": true, + "verifySpatial": true, + "verifyState": true, + "vis2": 0.25, + "vis2Coarse": 0.5, + "vis4": 0.0156, + "viscPC": false, + "viscWallTreatment": "constant pressure extrapolation", + "viscousSurfaceVelocities": true, + "volumeVariables": [ + "resrho" + ], + "wallDistCutoff": 1e+20, + "windAxis": false, + "writeSolutionDigits": 3, + "writeSolutionEachIter": false, + "writeSurfaceSolution": true, + "writeTecplotSurfaceSolution": false, + "writeVolumeSolution": true, + "zipperSurfaceFamily": null + } +} \ No newline at end of file diff --git a/tests/reg_tests/refs/funcs_rans_rough_sa.json b/tests/reg_tests/refs/funcs_rans_rough_sa.json new file mode 100644 index 000000000..895d67e8b --- /dev/null +++ b/tests/reg_tests/refs/funcs_rans_rough_sa.json @@ -0,0 +1,1101 @@ +{ + "Dot product test for (w, xV) -> (dw, F)": 25051748893.868687, + "Dot product test for Xv -> R": -8183826.0616009245, + "Dot product test for w -> F": 48678.90552195639, + "Dot product test for w -> R": 25061252292.450912, + "Dot product test for xV -> F": -1368251.4261434944, + "Eval Functions:": { + "mdo_tutorial_cd": 0.024566400785789796, + "mdo_tutorial_cfx": 0.011668173003364507, + "mdo_tutorial_cfy": 0.4108141827884018, + "mdo_tutorial_cfz": 0.0075654034410337035, + "mdo_tutorial_cl": 0.4102449646172038, + "mdo_tutorial_cmx": -0.7922014856117325, + "mdo_tutorial_cmy": -0.008981003314113325, + "mdo_tutorial_cmz": 0.6295255266022379, + "mdo_tutorial_cofxx": 3.332310132439291, + "mdo_tutorial_cofxy": -0.1348493497186727, + "mdo_tutorial_cofxz": 1.6012560760241168, + "mdo_tutorial_cofyx": 4.97642146149654, + "mdo_tutorial_cofyy": 0.2601267269394276, + "mdo_tutorial_cofyz": 6.271918158078769, + "mdo_tutorial_cofzx": 6.327751594707444, + "mdo_tutorial_cofzy": 0.25617991212816216, + "mdo_tutorial_cofzz": 10.43278001294453, + "mdo_tutorial_colx": 4.977890283785735, + "mdo_tutorial_coly": 0.2604795921346493, + "mdo_tutorial_colz": 6.276090851527301, + "mdo_tutorial_drag": 10015.230272350786, + "mdo_tutorial_fx": 4756.880770011643, + "mdo_tutorial_fy": 167480.72603917567, + "mdo_tutorial_fz": 3084.2636748406208, + "mdo_tutorial_lift": 167248.6671751417, + "mdo_tutorial_mx": -1049635.2803761212, + "mdo_tutorial_my": -11899.470151067593, + "mdo_tutorial_mz": 834096.1417269012, + "mdo_tutorial_sepsensor": 0.016301194542570726, + "mdo_tutorial_sepsensoravgx": 0.09540342694812158, + "mdo_tutorial_sepsensoravgy": 9.994583497283502e-05, + "mdo_tutorial_sepsensoravgz": 0.05019620000103362 + }, + "Norm of residual": 2.2925508532857043e-16, + "Norm of state vector": 472.57778771100806, + "Sum of Forces x": 4756.880770011646, + "Sum of Forces y": 167480.72603917564, + "Sum of Forces z": 3084.263674840624, + "Sum of Tractions x": 336771.1069549067, + "Sum of Tractions y": 1650799.5101746526, + "Sum of Tractions z": 279940.1407894979, + "Total number of adjoint state DOF": { + "__ndarray__": 145152, + "dtype": "int64", + "shape": [] + }, + "Total number of spatial DOF": { + "__ndarray__": 91125, + "dtype": "int64", + "shape": [] + }, + "Total number of state DOF": { + "__ndarray__": 145152, + "dtype": "int64", + "shape": [] + }, + "dFuncs/dP": { + "cd": 1.025586307836628e-07, + "cfx": 1.0254457111038074e-07, + "cfy": 2.0585057746026076e-09, + "cfz": 3.080957025224556e-09, + "cl": -1.1635127916521157e-09, + "cmx": -5.02580368870114e-09, + "cmy": 1.836634687981284e-07, + "cmz": 2.0700897671058624e-09, + "cofxx": 1.037501293959403e-05, + "cofxy": 1.4128496198936057e-06, + "cofxz": 3.848381803761694e-05, + "cofyx": -2.090715333502599e-09, + "cofyy": 4.5109549389085536e-12, + "cofyz": 7.602063203362935e-09, + "cofzx": -4.184628224366399e-07, + "cofzy": -1.4398784783816656e-07, + "cofzz": -2.272928808272515e-06, + "colx": 1.551312768394871e-09, + "coly": 1.8444193827696344e-09, + "colz": 9.911171655450564e-09, + "drag": 0.5425726162154229, + "fx": 0.2796494092508621, + "fy": 8.374875513592974, + "fz": 0.1554692283020746, + "lift": 8.361959017862183, + "mx": -52.48842300766143, + "my": -0.35162675793461173, + "mz": 41.70754987248287, + "sepsensor": 0.0, + "sepsensoravgx": 0.0, + "sepsensoravgy": 0.0, + "sepsensoravgz": 0.0 + }, + "dFuncs/dT": { + "cd": -7.97407560708349e-21, + "cfx": -7.972667277561772e-21, + "cfy": -1.7008056169588572e-22, + "cfz": -2.2482267665849947e-22, + "cl": 8.043089385984346e-23, + "cmx": 4.087206383658274e-22, + "cmy": -1.4671395918848986e-20, + "cmz": -1.4513050628161639e-22, + "cofxx": -8.46577777879809e-19, + "cofxy": -1.1621669191703017e-19, + "cofxz": -3.0893539917499644e-18, + "cofyx": 2.2830502610902396e-22, + "cofyy": 4.3709209984172894e-24, + "cofyz": -5.698972668736165e-22, + "cofzx": 3.849894121230114e-20, + "cofzy": 1.1246443854871941e-20, + "cofzz": 1.811270017266413e-19, + "colx": -1.9081860443013808e-23, + "coly": -1.329751358440995e-22, + "colz": -6.623775130485751e-22, + "drag": -3.250871143495798e-15, + "fx": -3.250296995716384e-15, + "fy": -6.93384433921787e-17, + "fz": -9.165570882013707e-17, + "lift": 3.2790066808780993e-17, + "mx": 5.415384970091867e-16, + "my": -1.9439012736638154e-14, + "mz": -1.9229211560289045e-16, + "sepsensor": 0.0, + "sepsensoravgx": 0.0, + "sepsensoravgy": 0.0, + "sepsensoravgz": 0.0 + }, + "dFuncs/dXv * xVDot": { + "cd": 4.2529682732075225, + "cfx": 4.249035399663727, + "cfy": 0.19195702983176197, + "cfz": 0.3506482601505133, + "cl": 0.05839688337189065, + "cmx": -1.0927832721306239, + "cmy": -1.1999451606004583, + "cmz": 1.3595113636997622, + "cofxx": -488.09187989891825, + "cofxy": -76.51059615419034, + "cofxz": -739.7568018827052, + "cofyx": 4.862135728695632, + "cofyy": 0.37025124340482335, + "cofyz": 5.697393456600473, + "cofzx": -19.405430308047734, + "cofzy": -12.803792657294428, + "cofzz": -140.92641161911095, + "colx": 5.837204211267569, + "coly": 0.567383095306283, + "colz": 7.882287552102762, + "drag": 1733850.1056212431, + "fx": 1732246.7517349087, + "fy": 78257.04192181274, + "fz": 142952.2826981613, + "lift": 23807.241413052383, + "mx": -1447894.1242421914, + "my": -1589879.3399891835, + "mz": 1801298.1764476371, + "sepsensor": -0.11694957310130713, + "sepsensoravgx": -0.6029863600829567, + "sepsensoravgy": 0.007262037328436888, + "sepsensoravgz": -0.09612647922522868 + }, + "dFuncs/dalpha": { + "cd": 0.007160125372297845, + "cfx": 0.0, + "cfy": 0.0, + "cfz": 0.0, + "cl": -0.00042876457907655406, + "cmx": 0.0, + "cmy": 0.0, + "cmz": 0.0, + "cofxx": 0.0, + "cofxy": 0.0, + "cofxz": 0.0, + "cofyx": 0.0, + "cofyy": 0.0, + "cofyz": 0.0, + "cofzx": 0.0, + "cofzy": 0.0, + "cofzz": 0.0, + "colx": 0.0008172790369756601, + "coly": 0.0001963405165176115, + "colz": 0.0023217613923074195, + "drag": 2919.039911778386, + "fx": 0.0, + "fy": 0.0, + "fz": 0.0, + "lift": -174.79874359792956, + "mx": 0.0, + "my": 0.0, + "mz": 0.0, + "sepsensor": 0.0008890133278288019, + "sepsensoravgx": 0.006211849207427457, + "sepsensoravgy": 1.1629154598405563e-06, + "sepsensoravgz": 0.006150040814983931 + }, + "dFuncs/dbeta": { + "cd": -0.007561670371126668, + "cfx": 0.0, + "cfy": 0.0, + "cfz": 0.0, + "cl": 0.00023763506481515244, + "cmx": 0.0, + "cmy": 0.0, + "cmz": 0.0, + "cofxx": 0.0, + "cofxy": 0.0, + "cofxz": 0.0, + "cofyx": 0.0, + "cofyy": 0.0, + "cofyz": 0.0, + "cofzx": 0.0, + "cofzy": 0.0, + "cofzz": 0.0, + "colx": 0.0007819093658142975, + "coly": -2.490596656023271e-06, + "colz": 0.0024077689758154846, + "drag": -3082.7417769009207, + "fx": 0.0, + "fy": 0.0, + "fz": 0.0, + "lift": 96.87906322384137, + "mx": 0.0, + "my": 0.0, + "mz": 0.0, + "sepsensor": 0.181360493959623, + "sepsensoravgx": 1.1060754915788906, + "sepsensoravgy": 0.001164630699853899, + "sepsensoravgz": 0.7192972767550523 + }, + "dFuncs/dmach": { + "cd": -0.06141600196447446, + "cfx": -0.029170432508411257, + "cfy": -1.0270354569710043, + "cfz": -0.01891350860258426, + "cl": -1.0256124115430092, + "cmx": 1.9805037140293307, + "cmy": 0.02245250828528332, + "cmz": -1.5738138165055942, + "cofxx": 0.0, + "cofxy": 0.0, + "cofxz": 0.0, + "cofyx": 0.0, + "cofyy": 0.0, + "cofyz": 0.0, + "cofzx": 0.0, + "cofzy": 0.0, + "cofzz": 0.0, + "colx": 0.0, + "coly": 0.0, + "colz": 0.0, + "drag": 0.0, + "fx": 0.0, + "fy": 0.0, + "fz": 0.0, + "lift": 0.0, + "mx": 0.0, + "my": 0.0, + "mz": 0.0, + "sepsensor": 0.0, + "sepsensoravgx": 0.0, + "sepsensoravgy": 0.0, + "sepsensoravgz": 0.0 + }, + "dFuncs/dw * wDot": { + "cd": 0.031101767260431196, + "cfx": 0.028800395325415777, + "cfy": 0.07371942797663703, + "cfz": 0.021716000987843997, + "cl": 0.07277840961013626, + "cmx": -0.15842697054164165, + "cmy": 0.0050247716470549885, + "cmz": 0.12014382033187077, + "cofxx": -5.883673815216708, + "cofxy": 0.4009727991396247, + "cofxz": 10.11585037814496, + "cofyx": 0.05940247196308444, + "cofyy": -0.3350265708291385, + "cofyz": 0.127914595757047, + "cofzx": 1.3755158785313275, + "cofzy": -0.7322158660616279, + "cofzz": -15.884837396918154, + "colx": 0.06807682146337765, + "coly": -0.33487572734605553, + "colz": 0.12855069447564793, + "drag": 12679.568476732591, + "fx": 11741.345166265506, + "fy": 30053.936397515386, + "fz": 8853.179282724243, + "lift": 29670.30202986036, + "mx": -209909.39888885352, + "my": 6657.621441481978, + "mz": 159185.7561869155, + "sepsensor": -12.044419253289893, + "sepsensoravgx": -68.10234813562751, + "sepsensoravgy": -0.08084780944322405, + "sepsensoravgz": -28.399498948465336 + }, + "dFuncs/dxRef": { + "cd": 0.0, + "cfx": 0.0, + "cfy": 0.0, + "cfz": 0.0, + "cl": 0.0, + "cmx": 0.0, + "cmy": 0.0023278164433949864, + "cmz": -0.12640436393489288, + "cofxx": 0.0, + "cofxy": 0.0, + "cofxz": 0.0, + "cofyx": 0.0, + "cofyy": 0.0, + "cofyz": 0.0, + "cofzx": 0.0, + "cofzy": 0.0, + "cofzz": 0.0, + "colx": 0.0, + "coly": 0.0, + "colz": 0.0, + "drag": 0.0, + "fx": 0.0, + "fy": 0.0, + "fz": 0.0, + "lift": 0.0, + "mx": 0.0, + "my": 3084.2636748406217, + "mz": -167480.72603917567, + "sepsensor": 0.0, + "sepsensoravgx": 0.0, + "sepsensoravgy": 0.0, + "sepsensoravgz": 0.0 + }, + "dFuncs/dyRef": { + "cd": 0.0, + "cfx": 0.0, + "cfy": 0.0, + "cfz": 0.0, + "cl": 0.0, + "cmx": -0.0023278164433949864, + "cmy": 0.0, + "cmz": 0.003590207077958309, + "cofxx": 0.0, + "cofxy": 0.0, + "cofxz": 0.0, + "cofyx": 0.0, + "cofyy": 0.0, + "cofyz": 0.0, + "cofzx": 0.0, + "cofzy": 0.0, + "cofzz": 0.0, + "colx": 0.0, + "coly": 0.0, + "colz": 0.0, + "drag": 0.0, + "fx": 0.0, + "fy": 0.0, + "fz": 0.0, + "lift": 0.0, + "mx": -3084.2636748406217, + "my": 0.0, + "mz": 4756.880770011641, + "sepsensor": 0.0, + "sepsensoravgx": 0.0, + "sepsensoravgy": 0.0, + "sepsensoravgz": 0.0 + }, + "dFuncs/dzRef": { + "cd": 0.0, + "cfx": 0.0, + "cfy": 0.0, + "cfz": 0.0, + "cl": 0.0, + "cmx": 0.12640436393489285, + "cmy": -0.003590207077958309, + "cmz": 0.0, + "cofxx": 0.0, + "cofxy": 0.0, + "cofxz": 0.0, + "cofyx": 0.0, + "cofyy": 0.0, + "cofyz": 0.0, + "cofzx": 0.0, + "cofzy": 0.0, + "cofzz": 0.0, + "colx": 0.0, + "coly": 0.0, + "colz": 0.0, + "drag": 0.0, + "fx": 0.0, + "fy": 0.0, + "fz": 0.0, + "lift": 0.0, + "mx": 167480.72603917564, + "my": -4756.880770011641, + "mz": 0.0, + "sepsensor": 0.0, + "sepsensoravgx": 0.0, + "sepsensoravgy": 0.0, + "sepsensoravgz": 0.0 + }, + "metadata": { + "ADPC": false, + "ANKADPC": false, + "ANKAMGLevels": 2, + "ANKAMGNSmooth": 1, + "ANKASMOverlap": 1, + "ANKASMOverlapCoarse": 0, + "ANKCFL0": 5.0, + "ANKCFLCutback": 0.5, + "ANKCFLExponent": 0.5, + "ANKCFLFactor": 10.0, + "ANKCFLLimit": 100000.0, + "ANKCFLMin": 1.0, + "ANKCFLReset": true, + "ANKCharTimeStepType": "None", + "ANKConstCFLStep": 0.4, + "ANKCoupledSwitchTol": 1e-16, + "ANKGlobalPreconditioner": "additive Schwarz", + "ANKInnerPreconIts": 1, + "ANKInnerPreconItsCoarse": 1, + "ANKJacobianLag": 10, + "ANKLinResMax": 0.1, + "ANKLinearSolveBuffer": 0.01, + "ANKLinearSolveTol": 0.05, + "ANKMaxIter": 40, + "ANKNSubiterTurb": 1, + "ANKOuterPreconIts": 1, + "ANKPCILUFill": 2, + "ANKPCILUFillCoarse": 0, + "ANKPCUpdateCutoff": 1e-16, + "ANKPCUpdateTol": 0.5, + "ANKPCUpdateTolAfterCutoff": 0.0001, + "ANKPhysicalLSTol": 0.2, + "ANKPhysicalLSTolTurb": 0.99, + "ANKSecondOrdSwitchTol": 0.01, + "ANKStepFactor": 1.0, + "ANKStepMin": 0.01, + "ANKSubspaceSize": -1, + "ANKSwitchTol": 0.01, + "ANKTurbCFLScale": 1.0, + "ANKTurbKSPDebug": false, + "ANKUnsteadyLSTol": 1.0, + "ANKUseApproxSA": false, + "ANKUseFullVisc": true, + "ANKUseMatrixFree": true, + "ANKUseTurbDADI": true, + "ASMOverlap": 1, + "ASMOverlapCoarse": 0, + "CFL": 1.5, + "CFLCoarse": 1.25, + "CFLLimit": 1.5, + "GMRESOrthogonalizationType": "modified Gram-Schmidt", + "ILUFill": 2, + "ILUFillCoarse": 0, + "L2Convergence": 1e-15, + "L2ConvergenceCoarse": 0.01, + "L2ConvergenceRel": 1e-16, + "MGCycle": "2w", + "MGStartLevel": -1, + "NKADPC": false, + "NKAMGLevels": 2, + "NKAMGNSmooth": 1, + "NKASMOverlap": 1, + "NKASMOverlapCoarse": 0, + "NKFixedStep": 0.25, + "NKGlobalPreconditioner": "additive Schwarz", + "NKInnerPreconIts": 1, + "NKInnerPreconItsCoarse": 1, + "NKJacobianLag": 2, + "NKLS": "cubic", + "NKLinearSolveTol": 0.3, + "NKOuterPreconIts": 1, + "NKPCILUFill": 2, + "NKPCILUFillCoarse": 0, + "NKSubspaceSize": 60, + "NKSwitchTol": 1e-05, + "NKUseEW": true, + "NKViscPC": false, + "RKReset": false, + "TSStability": false, + "acousticScaleFactor": 1.0, + "adjointAMGLevels": 2, + "adjointAMGNSmooth": 1, + "adjointDivTol": 100000.0, + "adjointL2Convergence": 1e-16, + "adjointL2ConvergenceAbs": 1e-16, + "adjointL2ConvergenceRel": 1e-16, + "adjointMaxIter": 500, + "adjointMaxL2DeviationFactor": 1.0, + "adjointMonitorStep": 10, + "adjointSolver": "GMRES", + "adjointSubspaceSize": 100, + "alphaFollowing": true, + "alphaMode": false, + "altitudeMode": false, + "applyAdjointPCSubspaceSize": 20, + "applyPCSubspaceSize": 10, + "approxPC": true, + "backgroundVolScale": 1.0, + "betaMode": false, + "blockSplitting": true, + "cavExponent": 0, + "cavSensorOffset": 0.0, + "cavSensorSharpness": 10.0, + "cavitationNumber": 1.4, + "closedSurfaceFamilies": null, + "coarseDiscretization": "central plus scalar dissipation", + "computeCavitation": false, + "coupledSolution": false, + "cpMinRho": 100.0, + "cutCallback": null, + "debugZipper": false, + "deltaT": 0.01, + "designSurfaceFamily": null, + "discretization": "central plus scalar dissipation", + "dissContMagnitude": 1.0, + "dissContMidpoint": 3.0, + "dissContSharpness": 3.0, + "dissipationLumpingParameter": 6.0, + "dissipationScalingExponent": 0.67, + "eddyVisInfRatio": 0.009, + "equationMode": "steady", + "equationType": "RANS", + "eulerWallTreatment": "linear pressure extrapolation", + "explicitSurfaceCallback": null, + "firstRun": true, + "flowType": "external", + "forcesAsTractions": true, + "frozenTurbulence": false, + "globalPreconditioner": "additive Schwarz", + "gridFile": "input_files/mdo_tutorial_rough.cgns", + "gridPrecision": "double", + "gridPrecisionSurface": "single", + "infChangeCorrection": true, + "infChangeCorrectionTol": 1e-12, + "infChangeCorrectionType": "offset", + "innerPreconIts": 1, + "innerPreconItsCoarse": 1, + "isoVariables": [], + "isosurface": {}, + "liftIndex": 2, + "limiter": "van Albada", + "loadBalanceIter": 10, + "loadImbalance": 0.1, + "localPreconditioner": "ILU", + "lowSpeedPreconditioner": false, + "machMode": false, + "matrixOrdering": "RCM", + "maxL2DeviationFactor": 1.0, + "meshMaxSkewness": 1.0, + "meshSurfaceFamily": null, + "monitorVariables": [ + "cpu", + "resrho", + "resturb", + "cl", + "cd", + "cmz", + "yplus", + "totalr" + ], + "nCycles": 1000, + "nCyclesCoarse": 100, + "nFloodIter": -1, + "nRKReset": 5, + "nRefine": 10, + "nSaveSurface": 1, + "nSaveVolume": 1, + "nSubiter": 3, + "nSubiterTurb": 3, + "nTimeStepsCoarse": 48, + "nTimeStepsFine": 400, + "nearWallDist": 0.1, + "numberSolutions": true, + "outerPreconIts": 3, + "outputDirectory": "tests/output_files", + "outputSurfaceFamily": "allSurfaces", + "overlapFactor": 0.9, + "oversetDebugPrint": false, + "oversetLoadBalance": true, + "oversetPriority": {}, + "oversetProjTol": 1e-12, + "oversetUpdateMode": "frozen", + "pMode": false, + "partitionLikeNProc": -1, + "partitionOnly": false, + "preconditionerSide": "right", + "printAllOptions": true, + "printBadlySkewedCells": false, + "printIntro": true, + "printIterations": true, + "printNegativeVolumes": false, + "printTiming": true, + "printWarnings": true, + "qMode": false, + "rMode": false, + "recomputeOverlapMatrix": true, + "resAveraging": "never", + "restartAdjoint": true, + "restartFile": "input_files/mdo_tutorial_rough.cgns", + "restrictionRelaxation": 0.8, + "selfZipCutoff": 120.0, + "sepSensorOffset": 0.0, + "sepSensorSharpness": 10.0, + "setMonitor": true, + "skipAfterFailedAdjoint": true, + "smoothParameter": 1.5, + "smoother": "DADI", + "solutionPrecision": "single", + "solutionPrecisionSurface": "single", + "storeConvHist": true, + "storeRindLayer": true, + "surfaceVariables": [ + "cp", + "vx", + "vy", + "vz", + "mach" + ], + "timeAccuracy": 2, + "timeIntegrationScheme": "BDF", + "timeIntervals": 1, + "timeLimit": -1.0, + "turbResScale": 10000.0, + "turbulenceModel": "SA", + "turbulenceOrder": "first order", + "turbulenceProduction": "strain", + "updateWallAssociations": false, + "useALE": true, + "useANKSolver": true, + "useApproxWallDistance": true, + "useBlockettes": false, + "useDiagTSPC": true, + "useDissContinuation": false, + "useExternalDynamicMesh": false, + "useGridMotion": false, + "useLinResMonitor": false, + "useMatrixFreedrdw": true, + "useNKSolver": true, + "useOversetWallScaling": false, + "useQCR": false, + "useRotationSA": false, + "useRoughSA": true, + "useSkewnessCheck": false, + "useTSInterpolatedGridVelocity": false, + "useWallFunctions": false, + "useZipperMesh": true, + "useft2SA": true, + "verifyExtra": true, + "verifySpatial": true, + "verifyState": true, + "vis2": 0.25, + "vis2Coarse": 0.5, + "vis4": 0.0156, + "viscPC": false, + "viscWallTreatment": "constant pressure extrapolation", + "viscousSurfaceVelocities": true, + "volumeVariables": [ + "resrho" + ], + "wallDistCutoff": 1e+20, + "windAxis": false, + "writeSolutionDigits": 3, + "writeSolutionEachIter": false, + "writeSurfaceSolution": true, + "writeTecplotSurfaceSolution": false, + "writeVolumeSolution": true, + "zipperSurfaceFamily": null + }, + "||FBar^T * dF/dXv||": 47500739.33793807, + "||FBar^T * dF/dw||": 159520.82502357475, + "||FBar^T * dF/xDv||": { + "P_mdo_tutorial": 57.28609964209288, + "T_mdo_tutorial": 3.552713678800501e-14, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dF/dP||": 5.5922286389459215, + "||dF/dT||": 1.4357072986878935e-15, + "||dF/dXv * xVDot||": 7581135.361357854, + "||dF/dalpha||": 0.0, + "||dF/dbeta||": 0.0, + "||dF/dmach||": 0.0, + "||dF/dw * wDot||": 131479.67592004602, + "||dF/dxRef||": 0.0, + "||dF/dyRef||": 0.0, + "||dF/dzRef||": 0.0, + "||dR/dP||": 0.07356605182246514, + "||dR/dT||": 9.220630057589264e-07, + "||dR/dXv * xVDot||": 26726959.34145183, + "||dR/dalpha||": 0.010271084828244875, + "||dR/dbeta||": 0.6070879776942455, + "||dR/dmach||": 0.9283860217641269, + "||dR/dw * wDot||": 2695502679.787602, + "||dR/dxRef||": 0.0, + "||dR/dyRef||": 0.0, + "||dR/dzRef||": 0.0, + "||dcd/dXdv||": { + "P_mdo_tutorial": 1.0255863078366487e-07, + "T_mdo_tutorial": -1.6940658945086007e-21, + "alpha_mdo_tutorial": 0.007160125372297845, + "beta_mdo_tutorial": -0.00013197604492666198, + "mach_mdo_tutorial": -0.06141600196447446, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcd/dXv||": 27.91337076794424, + "||dcd/dw||": 0.014161257652762544, + "||dcfx/dXdv||": { + "P_mdo_tutorial": 1.0254457111038457e-07, + "T_mdo_tutorial": 1.8634724839594607e-20, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": -0.029170432508411247, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcfx/dXv||": 27.91271619511463, + "||dcfx/dw||": 0.014090362780761695, + "||dcfy/dXdv||": { + "P_mdo_tutorial": 2.058505774629507e-09, + "T_mdo_tutorial": 1.164670302474663e-21, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": -1.027035456971004, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcfy/dXv||": 2.7931029821306073, + "||dcfy/dw||": 0.11354907277670545, + "||dcfz/dXdv||": { + "P_mdo_tutorial": 3.08095702522557e-09, + "T_mdo_tutorial": 1.0587911840678754e-22, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": -0.018913508602584266, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcfz/dXv||": 2.519605387991788, + "||dcfz/dw||": 0.007655345743081827, + "||dcl/dXdv||": { + "P_mdo_tutorial": -1.163512791604249e-09, + "T_mdo_tutorial": 5.293955920339377e-22, + "alpha_mdo_tutorial": -0.000428764579076554, + "beta_mdo_tutorial": 4.147514299214542e-06, + "mach_mdo_tutorial": -1.0256124115430092, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcl/dXv||": 2.7865537908099736, + "||dcl/dw||": 0.11354025292131027, + "||dcmx/dXdv||": { + "P_mdo_tutorial": -5.025803688770831e-09, + "T_mdo_tutorial": 5.293955920339377e-22, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 1.9805037140293307, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": -0.0023278164433949877, + "zRef_mdo_tutorial": 0.12640436393489274 + }, + "||dcmx/dXv||": 5.614216937125317, + "||dcmx/dw||": 0.21272941416694607, + "||dcmy/dXdv||": { + "P_mdo_tutorial": 1.8366346879813508e-07, + "T_mdo_tutorial": -6.437450399132683e-20, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.022452508285283317, + "xRef_mdo_tutorial": 0.0023278164433949877, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": -0.003590207077958317 + }, + "||dcmy/dXv||": 54.53814156559551, + "||dcmy/dw||": 0.033839731077361684, + "||dcmz/dXdv||": { + "P_mdo_tutorial": 2.0700897671831215e-09, + "T_mdo_tutorial": 2.4980854499101436e-22, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": -1.5738138165055942, + "xRef_mdo_tutorial": -0.12640436393489274, + "yRef_mdo_tutorial": 0.003590207077958317, + "zRef_mdo_tutorial": 0.0 + }, + "||dcmz/dXv||": 3.6697227583365826, + "||dcmz/dw||": 0.1701587174303123, + "||dcofxx/dXdv||": { + "P_mdo_tutorial": 1.0375012939594107e-05, + "T_mdo_tutorial": -2.168404344971009e-19, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcofxx/dXv||": 3932.1540349438337, + "||dcofxx/dw||": 2.443894963885116, + "||dcofxy/dXdv||": { + "P_mdo_tutorial": 1.4128496198935765e-06, + "T_mdo_tutorial": 9.063252535621014e-20, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcofxy/dXv||": 623.1593133276406, + "||dcofxy/dw||": 0.23025338834961076, + "||dcofxz/dXdv||": { + "P_mdo_tutorial": 3.848381803761748e-05, + "T_mdo_tutorial": -4.336808689942018e-18, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcofxz/dXv||": 11552.29885023033, + "||dcofxz/dw||": 5.698262110691424, + "||dcofyx/dXdv||": { + "P_mdo_tutorial": -2.0907153332327543e-09, + "T_mdo_tutorial": 3.8116482626443515e-21, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcofyx/dXv||": 12.79568795413275, + "||dcofyx/dw||": 0.4192809957752443, + "||dcofyy/dXdv||": { + "P_mdo_tutorial": 4.510954947963962e-12, + "T_mdo_tutorial": 3.705769144237564e-22, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcofyy/dXv||": 1.9032269476611576, + "||dcofyy/dw||": 0.0825146038902352, + "||dcofyz/dXdv||": { + "P_mdo_tutorial": 7.602063203682738e-09, + "T_mdo_tutorial": 1.5881867761018131e-21, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcofyz/dXv||": 20.030844678339538, + "||dcofyz/dw||": 0.8509322500970162, + "||dcofzx/dXdv||": { + "P_mdo_tutorial": -4.184628224365662e-07, + "T_mdo_tutorial": 1.2197274440461925e-19, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcofzx/dXv||": 827.0135715836623, + "||dcofzx/dw||": 2.862119939722487, + "||dcofzy/dXdv||": { + "P_mdo_tutorial": -1.4398784783813178e-07, + "T_mdo_tutorial": 8.470329472543003e-22, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcofzy/dXv||": 83.78696877492811, + "||dcofzy/dw||": 0.29477884488655265, + "||dcofzz/dXdv||": { + "P_mdo_tutorial": -2.272928808272855e-06, + "T_mdo_tutorial": -9.486769009248164e-20, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcofzz/dXv||": 1682.3717949452966, + "||dcofzz/dw||": 5.947434235310889, + "||dcolx/dXdv||": { + "P_mdo_tutorial": 1.5513127686803932e-09, + "T_mdo_tutorial": -8.470329472543003e-22, + "alpha_mdo_tutorial": 0.0008172790369756611, + "beta_mdo_tutorial": 1.3646892885640295e-05, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcolx/dXv||": 12.775631153550293, + "||dcolx/dw||": 0.41986360397311606, + "||dcoly/dXdv||": { + "P_mdo_tutorial": 1.844419382777588e-09, + "T_mdo_tutorial": -3.970466940254533e-22, + "alpha_mdo_tutorial": 0.00019634051651761149, + "beta_mdo_tutorial": -4.346911198676798e-08, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcoly/dXv||": 2.121373186987298, + "||dcoly/dw||": 0.08274333483032113, + "||dcolz/dXdv||": { + "P_mdo_tutorial": 9.911171655798822e-09, + "T_mdo_tutorial": 4.235164736271502e-22, + "alpha_mdo_tutorial": 0.0023217613923074195, + "beta_mdo_tutorial": 4.202349625535192e-05, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dcolz/dXv||": 20.13173905846084, + "||dcolz/dw||": 0.852397192595701, + "||ddrag/dXdv||": { + "P_mdo_tutorial": 0.5425726162154232, + "T_mdo_tutorial": -3.552713678800501e-15, + "alpha_mdo_tutorial": 2919.0399117783863, + "beta_mdo_tutorial": -53.80399399570157, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||ddrag/dXv||": 11379722.99467551, + "||ddrag/dw||": 5773.261519878235, + "||dfx/dXdv||": { + "P_mdo_tutorial": 0.2796494092508623, + "T_mdo_tutorial": -2.6645352591003757e-15, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dfx/dXv||": 11379456.138424333, + "||dfx/dw||": 5744.359098460929, + "||dfy/dXdv||": { + "P_mdo_tutorial": 8.374875513592984, + "T_mdo_tutorial": 1.249000902703301e-16, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dfy/dXv||": 1138692.223755006, + "||dfy/dw||": 46291.685989607286, + "||dfz/dXdv||": { + "P_mdo_tutorial": 0.15546922830207505, + "T_mdo_tutorial": -8.326672684688674e-17, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dfz/dXv||": 1027192.7245764921, + "||dfz/dw||": 3120.9313525395996, + "||dlift/dXdv||": { + "P_mdo_tutorial": 8.361959017862175, + "T_mdo_tutorial": -8.326672684688674e-17, + "alpha_mdo_tutorial": -174.7987435979296, + "beta_mdo_tutorial": 1.6908586295037848, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dlift/dXv||": 1136022.2494374104, + "||dlift/dw||": 46288.09031095977, + "||dmx/dXdv||": { + "P_mdo_tutorial": -52.48842300766146, + "T_mdo_tutorial": -4.163336342344337e-15, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": -3084.263674840623, + "zRef_mdo_tutorial": 167480.72603917567 + }, + "||dmx/dXv||": 7438612.87301356, + "||dmx/dw||": 281857.96459463687, + "||dmy/dXdv||": { + "P_mdo_tutorial": -0.3516267579346164, + "T_mdo_tutorial": 6.750155989720952e-14, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 3084.263674840623, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": -4756.880770011646 + }, + "||dmy/dXv||": 72260856.04875143, + "||dmy/dw||": 44836.290088261136, + "||dmz/dXdv||": { + "P_mdo_tutorial": 41.70754987248288, + "T_mdo_tutorial": -7.181755190543981e-16, + "alpha_mdo_tutorial": 0.0, + "beta_mdo_tutorial": 0.0, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": -167480.72603917567, + "yRef_mdo_tutorial": 4756.880770011646, + "zRef_mdo_tutorial": 0.0 + }, + "||dmz/dXv||": 4862235.86588564, + "||dmz/dw||": 225453.4942464666, + "||dsepsensor/dXdv||": { + "P_mdo_tutorial": 0.0, + "T_mdo_tutorial": 0.0, + "alpha_mdo_tutorial": 0.0008890133278288006, + "beta_mdo_tutorial": 0.00316533775263871, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dsepsensor/dXv||": 0.5244726837411959, + "||dsepsensor/dw||": 8.307879565539196, + "||dsepsensoravgx/dXdv||": { + "P_mdo_tutorial": 0.0, + "T_mdo_tutorial": 0.0, + "alpha_mdo_tutorial": 0.0062118492074274565, + "beta_mdo_tutorial": 0.01930465910366646, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dsepsensoravgx/dXv||": 3.3555033669837817, + "||dsepsensoravgx/dw||": 42.297878810572435, + "||dsepsensoravgy/dXdv||": { + "P_mdo_tutorial": 0.0, + "T_mdo_tutorial": 0.0, + "alpha_mdo_tutorial": 1.1629154598405582e-06, + "beta_mdo_tutorial": 2.0326640282256375e-05, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dsepsensoravgy/dXv||": 0.003795589801898465, + "||dsepsensoravgy/dw||": 0.07333646978426117, + "||dsepsensoravgz/dXdv||": { + "P_mdo_tutorial": 0.0, + "T_mdo_tutorial": 0.0, + "alpha_mdo_tutorial": 0.006150040814983934, + "beta_mdo_tutorial": 0.01255410578000454, + "mach_mdo_tutorial": 0.0, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + }, + "||dsepsensoravgz/dXv||": 3.3049236735056238, + "||dsepsensoravgz/dw||": 10.598482329462021, + "||dwBar^T * dR/dXv||": 108834126.81700659, + "||dwBar^T * dR/dw||": 2217397593.2762737, + "||dwBar^T * dR/xDv||": { + "P_mdo_tutorial": 0.8893628179225483, + "T_mdo_tutorial": -7.760276830026669e-06, + "alpha_mdo_tutorial": -0.002000483758618282, + "beta_mdo_tutorial": -0.025156969826716998, + "mach_mdo_tutorial": -3.283371024149603, + "xRef_mdo_tutorial": 0.0, + "yRef_mdo_tutorial": 0.0, + "zRef_mdo_tutorial": 0.0 + } +} \ No newline at end of file diff --git a/tests/reg_tests/test_adjoint.py b/tests/reg_tests/test_adjoint.py index 10eecfa2a..3b24fdb34 100644 --- a/tests/reg_tests/test_adjoint.py +++ b/tests/reg_tests/test_adjoint.py @@ -208,6 +208,44 @@ def span(val, geo): "evalFuncs": ["fy", "my"], "N_PROCS": 2, }, + # Rough SA test + { + "name": "Rough_SA_wing", + "options": { + "gridFile": os.path.join(baseDir, "../../input_files/mdo_tutorial_rough.cgns"), + "restartFile": os.path.join(baseDir, "../../input_files/mdo_tutorial_rough.cgns"), + "equationType": "RANS", + "useBlockettes": False, + "useRoughSA": True, + "MGCycle": "2w", + "equationType": "RANS", + "smoother": "DADI", + "CFL": 1.5, + "CFLCoarse": 1.25, + "resAveraging": "never", + "nSubiter": 3, + "nSubiterTurb": 3, + "nCyclesCoarse": 100, + "nCycles": 1000, + "monitorVariables": ["resrho", "resturb", "cd"], + "volumeVariables": ["resrho"], + "useNKsolver": True, + "ANKSwitchTol": 1e-2, + "ANKSecondordSwitchTol": 1e-2, + "NKSwitchTol": 1e-5, + "NKjacobianlag": 2, + "L2Convergence": 1e-15, + "adjointL2Convergence": 1e-16, + # to get slightly better complex convergence + "NKUseEW": False, + "NKLinearSolveTol": 1e-6, + }, + "ref_file": "adjoint_rans_rough_sa.json", + "aero_prob": ap_tutorial_wing, + "evalFuncs": ["cl", "cd", "cmz", "lift", "drag"], + # "evalFuncs": ["cd"], + "N_PROCS": 2, + }, ] diff --git a/tests/reg_tests/test_functionals.py b/tests/reg_tests/test_functionals.py index 4631ee626..d18a6e26b 100644 --- a/tests/reg_tests/test_functionals.py +++ b/tests/reg_tests/test_functionals.py @@ -211,6 +211,73 @@ "aero_prob": ap_CRM, "dot_prod_tol": 1e-10, }, + # Rough SA test + { + "name": "Rough_SA_wing", + "options": { + "gridFile": os.path.join(baseDir, "../../input_files/mdo_tutorial_rough.cgns"), + "restartFile": os.path.join(baseDir, "../../input_files/mdo_tutorial_rough.cgns"), + "equationType": "RANS", + "useBlockettes": False, + "useRoughSA": True, + "MGCycle": "2w", + "equationType": "RANS", + "smoother": "DADI", + "CFL": 1.5, + "CFLCoarse": 1.25, + "resAveraging": "never", + "nSubiter": 3, + "nSubiterTurb": 3, + "nCyclesCoarse": 100, + "nCycles": 1000, + "monitorVariables": ["cpu", "resrho", "resturb", "cl", "cd", "cmz", "yplus", "totalr"], + "useNKsolver": True, + "ANKSwitchTol": 1e-2, + "ANKSecondordSwitchTol": 1e-2, + "L2Convergence": 1e-15, + "NKSwitchTol": 1e-5, + "adjointL2Convergence": 1e-16, + "blockSplitting": True, + "NKjacobianlag": 2, + }, + "ref_file": "funcs_rans_rough_sa.json", + "aero_prob": ap_tutorial_wing, + "dot_prod_tol": 1e-10, + }, + # Rough Tutorial wing RANS + # This test makes sure a roughness value of 0 equals the standard SA model + # It checks if the outcome is consistent with the test 'rans_tut_wing' + { + "name": "Rough_SA_rans_tut_wing", + "options": { + "gridfile": os.path.join(baseDir, "../../input_files/mdo_tutorial_rans_scalar_jst.cgns"), + "restartfile": os.path.join(baseDir, "../../input_files/mdo_tutorial_rans_scalar_jst.cgns"), + "useBlockettes": False, + "useRoughSA": True, + "mgcycle": "sg", + "equationtype": "RANS", + "smoother": "DADI", + "cfl": 1.5, + "cflcoarse": 1.25, + "resaveraging": "never", + "nsubiter": 3, + "nsubiterturb": 3, + "ncyclescoarse": 100, + "ncycles": 1000, + "monitorvariables": ["cpu", "resrho", "resturb", "cl", "cd", "cmz", "yplus", "totalr"], + "usenksolver": True, + "l2convergence": 1e-14, + "l2convergencecoarse": 1e-4, + "nkswitchtol": 1e-3, + "adjointl2convergence": 1e-14, + "frozenturbulence": False, + }, + "ref_file": "funcs_rans_tut_wing.json", + "aero_prob": ap_tutorial_wing, + "no_train": True, # This test should not be able to over-write + # the training file as it is coming from a different test + "dot_prod_tol": 1e-10, + }, ] ) class TestFunctionals(reg_test_classes.RegTest): diff --git a/tests/reg_tests/test_jacVecProdBWDFast.py b/tests/reg_tests/test_jacVecProdBWDFast.py index 67d4c4a71..f56091c57 100644 --- a/tests/reg_tests/test_jacVecProdBWDFast.py +++ b/tests/reg_tests/test_jacVecProdBWDFast.py @@ -33,6 +33,40 @@ "aero_prob": copy.deepcopy(ap_tutorial_wing), "N_PROCS": 1, }, + + { + "name": "rough_sa_tut_wing_1core", + "options": { + "gridFile": os.path.join(baseDir, "../../input_files/mdo_tutorial_rough.cgns"), + "restartFile": os.path.join(baseDir, "../../input_files/mdo_tutorial_rough.cgns"), + "equationType": "RANS", + "useBlockettes": False, + "useRoughSA": True, + "MGCycle": "2w", + "equationType": "RANS", + "smoother": "DADI", + "CFL": 1.5, + "CFLCoarse": 1.25, + "resAveraging": "never", + "nSubiter": 3, + "nSubiterTurb": 3, + "nCyclesCoarse": 100, + "nCycles": 1000, + "monitorVariables": ["cpu", "resrho", "resturb", "cl", "cd", "cmz", "yplus", "totalr"], + "useNKsolver": True, + "ANKSwitchTol": 1e-2, + "ANKSecondordSwitchTol": 1e-2, + "L2Convergence": 1e-15, + "NKSwitchTol": 1e-5, + "adjointL2Convergence": 1e-16, + "blockSplitting": True, + "NKjacobianlag": 2, + + }, + "ref_file": "funcs_rans_rough_sa.json", + "aero_prob": copy.deepcopy(ap_tutorial_wing), + "N_PROCS": 1, + }, ] diff --git a/tests/reg_tests/test_jacVecProdFWD.py b/tests/reg_tests/test_jacVecProdFWD.py index 5b8ac34a8..bf5b1b9e4 100644 --- a/tests/reg_tests/test_jacVecProdFWD.py +++ b/tests/reg_tests/test_jacVecProdFWD.py @@ -35,6 +35,41 @@ "aero_prob": copy.deepcopy(ap_tutorial_wing), "N_PROCS": 1, }, + + { + "name": "rough_sa_tut_wing_1core", + "options": { + "gridFile": os.path.join(baseDir, "../../input_files/mdo_tutorial_rough.cgns"), + "restartFile": os.path.join(baseDir, "../../input_files/mdo_tutorial_rough.cgns"), + "equationType": "RANS", + "useBlockettes": False, + "useRoughSA": True, + "MGCycle": "2w", + "equationType": "RANS", + "smoother": "DADI", + "CFL": 1.5, + "CFLCoarse": 1.25, + "resAveraging": "never", + "nSubiter": 3, + "nSubiterTurb": 3, + "nCyclesCoarse": 100, + "nCycles": 1000, + "monitorVariables": ["cpu", "resrho", "resturb", "cl", "cd", "cmz", "yplus", "totalr"], + "useNKsolver": True, + "ANKSwitchTol": 1e-2, + "ANKSecondordSwitchTol": 1e-2, + "L2Convergence": 1e-15, + "NKSwitchTol": 1e-5, + "adjointL2Convergence": 1e-16, + "blockSplitting": True, + "NKjacobianlag": 2, + + }, + "ref_file": "funcs_rans_rough_sa.json", + "aero_prob": copy.deepcopy(ap_tutorial_wing), + "N_PROCS": 1, + }, + ]