Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time spectral with flexible grid #169

Merged
merged 19 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions adflow/pyADflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2594,9 +2594,9 @@ def getIblankCheckSum(self, fileName=None):
# i.e. an Aerostructural solver
# =========================================================================

def getSurfaceCoordinates(self, groupName=None, includeZipper=True):
def getSurfaceCoordinates(self, groupName=None, includeZipper=True, TS=0):
# This is an alias for getSurfacePoints
return self.getSurfacePoints(groupName, includeZipper)
return self.getSurfacePoints(groupName, includeZipper, TS)

def getPointSetName(self, apName):
"""
Expand Down Expand Up @@ -2940,6 +2940,19 @@ def _setAeroProblemData(self, aeroProblem, firstCall=False):
# 4. Periodic Parameters --- These are not checked/verified
# and come directly from aeroProblem. Make sure you specify
# them there properly!!
if self.getOption("useExternalDynamicMesh"):
# The inputs here are mainly used for TS stability problem.
# For general aeroelastic problem, we rely on more general settings.
# Currently, polynomial motion is not supported for aeroelastic problem.
AP.degreePol = 0
AP.coefPol = [0.0]
# no odd number of instance allowed!
AP.degreeFourier = (self.adflow.inputtimespectral.ntimeintervalsspectral - 1) // 2
AP.cosCoefFourier = [0.0]
AP.sinCoefFourier = [0.0]
# if use time spectral, we need one of the following
# to be true to get a correct time period.
sseraj marked this conversation as resolved.
Show resolved Hide resolved
# the number of time instance is set directly.
if self.getOption("alphaMode"):
self.adflow.inputmotion.degreepolalpha = int(AP.degreePol)
self.adflow.inputmotion.coefpolalpha = AP.coefPol
Expand Down Expand Up @@ -2983,6 +2996,9 @@ def _setAeroProblemData(self, aeroProblem, firstCall=False):
self.adflow.inputmotion.degreefouryrot = AP.degreeFourier
self.adflow.inputmotion.coscoeffouryrot = AP.cosCoefFourier
self.adflow.inputmotion.sincoeffouryrot = AP.sinCoefFourier
elif self.getOption("useExternalDynamicMesh"):
# if it is an aeroelastic case
self.adflow.inputtimespectral.omegafourier = AP.omegaFourier

# Set any possible BC Data coming out of the aeroProblem
nameArray, dataArray, groupArray, groupNames, empty = self._getBCDataFromAeroProblem(AP)
Expand Down Expand Up @@ -3604,7 +3620,10 @@ def updateGeometryInfo(self, warpMesh=True):
self.adflow.killsignals.routinefailed = False
self.adflow.killsignals.fatalFail = False
self.updateTime = time.time() - timeA
if newGrid is not None:
if newGrid is not None and not self.getOption("useExternalDynamicMesh"):
# since updateGeometryInfo assumes one time slice
# when using ts with externally defined mesh, the grid is provided externally;
# updateGeometryInfo mainly serves to update the metrics and etc.
self.adflow.warping.setgrid(newGrid)
# Update geometric data, depending on the type of simulation
if self.getOption("equationMode").lower() == "unsteady":
Expand Down Expand Up @@ -4762,6 +4781,8 @@ def _getDefaultOptions():
"windAxis": [bool, False],
"alphaFollowing": [bool, True],
"TSStability": [bool, False],
"useTSInterpolatedGridVelocity": [bool, False],
sseraj marked this conversation as resolved.
Show resolved Hide resolved
"useExternalDynamicMesh": [bool, False],
# Convergence Parameters
"L2Convergence": [float, 1e-8],
"L2ConvergenceRel": [float, 1e-16],
Expand Down Expand Up @@ -5117,6 +5138,7 @@ def _getOptionMap(self):
"windaxis": ["stab", "usewindaxis"],
"alphafollowing": ["stab", "tsalphafollowing"],
"tsstability": ["stab", "tsstability"],
"usetsinterpolatedgridvelocity": ["ts", "usetsinterpolatedgridvelocity"],
# Convergence Parameters
"l2convergence": ["iter", "l2conv"],
"l2convergencerel": ["iter", "l2convrel"],
Expand Down Expand Up @@ -5272,6 +5294,7 @@ def _getSpecialOptionLists(self):
"cutcallback",
"infchangecorrection",
"skipafterfailedadjoint",
"useexternaldynamicmesh",
}

# Deprecated options that may be in old scripts and should not be used.
Expand Down
8 changes: 8 additions & 0 deletions doc/options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,14 @@ useALE:
desc: >
Use the arbitrary Lagrangian-Eulerian (ALE) formulation for unsteady mesh deformations.

useExternalDynamicMesh:
desc: >
Use externally provided deformed mesh for the time spectral equation. Each time instance gets its own deformed grid. This can be used for both an aerodynamic case or an aeroelastic case.

useTSInterpolatedGridVelocity:
desc: >
Use spectral differentiation to compute the grid velocity for the time spectral equation.

sseraj marked this conversation as resolved.
Show resolved Hide resolved
useGridMotion:
desc: >
Whether or not a rigid body motion of the grid has been specified.
Expand Down
14 changes: 14 additions & 0 deletions src/f2py/adflow.pyf
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,18 @@ python module libadflow
integer(kind=inttype), optional,intent(in),check(len(famlist)>=nfamlist),depend(famlist) :: nfamlist=len(famlist)
integer(kind=inttype) intent(in) :: sps
end subroutine getsurfaceperturbation

subroutine setgridforoneinstance(grid,sps) ! in warping.F90:warping
use blockpointers, only: jl,x,il,ndom,kl
anilyil marked this conversation as resolved.
Show resolved Hide resolved
use section, only: sections,nsections
use inputphysics, only: equationmode
use preprocessingapi, only: xhalo
use utils, only: setpointers
use constants
real(kind=realtype) dimension(:),intent(in) :: grid
integer intent(in) :: sps
end subroutine setgridforoneinstance

end module warping

module surfaceutils
Expand Down Expand Up @@ -1176,11 +1188,13 @@ python module libadflow
real(kind=realtype) allocatable,dimension(:,:,:) :: dscalar
real(kind=realtype) allocatable,dimension(:,:,:) :: dvector
real(kind=realtype) :: dtunsteadyrestartspectral
logical :: usetsinterpolatedgridvelocity
logical :: writeunsteadyrestartspectral
integer(kind=inttype) :: nunsteadysolspectral
logical :: writeunsteadyvolspectral
logical :: writeunsteadysurfspectral
real(kind=realtype) allocatable,dimension(:,:,:) :: rotmatrixspectral
real(kind=realtype) :: omegafourier
end module inputtimespectral
module inputoverset
logical :: useoversetloadbalance
Expand Down
3 changes: 3 additions & 0 deletions src/modules/inputParam.F90
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@ module inputTimeSpectral

real(kind=realType), dimension(:,:,:), allocatable :: &
rotMatrixSpectral
logical :: useTSInterpolatedGridVelocity

real(kind=realType) :: omegaFourier

end module inputTimeSpectral

Expand Down
15 changes: 15 additions & 0 deletions src/partitioning/partitioning.F90
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ subroutine timePeriodSpectral
omegaFourYRot, omegaFourZRot, degreeFourMach, degreeFourAlpha, &
degreeFourBeta
use inputPhysics, only : equationMOde, flowType
use inputTimeSpectral, only : omegaFourier
use section, only : sections, nSections
use utils, only : terminate
implicit none
Expand Down Expand Up @@ -969,6 +970,20 @@ subroutine timePeriodSpectral
endif
endif

! aeroelastic case
if(omegaFourier > 0) then
tt = two*pi/omegaFourier

! Check if a time period was already determined. If so, try
! to determine a common time. Otherwise just copy the data.

if( timeDetermined ) then
timePeriod = commonTimeSpectral(timePeriod, tt)
else
timePeriod = tt
timeDetermined = .true.
endif
end if

!!$ ! Altitude.
!!$
Expand Down
6 changes: 5 additions & 1 deletion src/preprocessing/preprocessingAPI.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3851,6 +3851,7 @@ subroutine updateGridVelocitiesAllLevels
endif

call gridVelocitiesFineLevel(.false., t, mm)

call gridVelocitiesCoarseLevels(mm)
call normalVelocitiesAllLevels(mm)

Expand Down Expand Up @@ -3889,7 +3890,10 @@ subroutine updatePeriodicInfoAllLevels

call timePeriodSpectral
call timeRotMatricesSpectral
call fineGridSpectralCoor
! solve for the new grid only for rigid rotation with analytical deformation case
if (.NOT. usetsinterpolatedgridvelocity) then
call fineGridSpectralCoor
end if
call timeSpectralMatrices


Expand Down
Loading