Skip to content

Commit c7272dd

Browse files
committed
Merge branch 'bugfix.sponge.areas' into 'master'
Fix sponge by merging baseflow from wmles/particle.zles See merge request flexi/flexi!736
2 parents 9705c58 + b5c1018 commit c7272dd

File tree

20 files changed

+867
-281
lines changed

20 files changed

+867
-281
lines changed

regressioncheck/checks/naca/2D/parameter.ini

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
!=================================================================================================================================
2-
! Copyright (c) 2010-2024 Prof. Claus-Dieter Munz
2+
! Copyright (c) 2010-2024 Prof. Claus-Dieter Munz
33
! This file is part of FLEXI, a high-order accurate framework for numerically solving PDEs with discontinuous Galerkin methods.
44
! For more information see https://www.flexi-project.org and https://nrg.iag.uni-stuttgart.de/
55
!
@@ -69,34 +69,36 @@ RefState = (/1.,0.990268069,0.139173101,0.,4.4642857/) ! State(s)
6969
!=========================================================================================
7070
! Sponge
7171
!=========================================================================================
72-
SpongeLayer = T ! Turn on to employ sponge regions for reducing
73-
! reflections at boundaries.
74-
75-
SpongeDistance = 3.0 ! Length of sponge ramp. The sponge will have
76-
! maximum strength at the end of the ramp and after
77-
! that point.
78-
79-
damping = 1.0 ! Damping factor of sponge (0..1).
80-
81-
SpongeShape = 1 ! Set shape of sponge: 1: cartesian /
82-
! vector-aligned, 2: cylindrical
83-
84-
SpongexStart = (/2.0,0.,0./) ! Coordinates of start postion of sponge ramp
85-
! (shape=1) or center (shape=2).
86-
87-
SpongeViz = T ! Turn on to write a visualization file of the
88-
! sponge region and strength.
89-
90-
SpongeDir = (/1,0,0/) ! Direction vector of the spong ramp (SpongeShape=1)
91-
92-
SpongeBaseFlow = 4 ! Type of baseflow to be used for sponge. 1: fixed
93-
! state, 2: exact function, 3: read baseflow file,
94-
! 4: temporally varying, solution adaptive Pruett
95-
! baseflow
96-
97-
tempFilterWidth = 2 ! Temporal filter witdh used to advance Pruett
98-
! baseflow in time.)
99-
!SpongeBaseflowFile =
72+
SpongeLayer = T ! Turn on to employ sponge regions for reducing
73+
! reflections at boundaries.
74+
75+
SpongeDistance = 3.0 ! Length of sponge ramp. The sponge will have
76+
! maximum strength at the end of the ramp and after
77+
! that point.
78+
79+
damping = 1.0 ! Damping factor of sponge (0..1).
80+
81+
SpongeShape = 1 ! Set shape of sponge: 1: cartesian /
82+
! vector-aligned, 2: cylindrical
83+
84+
SpongexStart = (/2.0,0.,0./) ! Coordinates of start postion of sponge ramp
85+
! (shape=1) or center (shape=2).
86+
87+
SpongeViz = T ! Turn on to write a visualization file of the
88+
! sponge region and strength.
89+
90+
SpongeDir = (/1,0,0/) ! Direction vector of the spong ramp (SpongeShape=1)
91+
92+
SpongeBaseFlow = 4 ! Type of baseflow to be used for sponge. 1: fixed
93+
! state, 2: exact function, 3: read baseflow file,
94+
! 4: temporally varying, solution adaptive Pruett
95+
! baseflow
96+
97+
tempFilterWidthSponge = 2 ! Temporal filter witdh used to advance Pruett
98+
! baseflow in time.)
99+
100+
BaseFlowRefState = 1 ! Specify which refstate should be used in no baseflowfile is given.
101+
100102
!=========================================================================================
101103
! Riemann
102104
!=========================================================================================
@@ -134,8 +136,8 @@ nWriteData = 1 ! Intervall as multiple of Analyze_dt at w
134136
!=========================================================================================
135137
! AnalyzeEquation
136138
!=========================================================================================
137-
CalcBodyForces = T ! Set true to compute body forces at walls
138-
CalcWallVelocity = T ! Set true to compute velocities at wall boundaries
139-
CalcTimeAverage = F ! Set true to compute time averages
140-
WriteBodyForces = T ! Set true to write bodyforces to file
141-
WriteWallVelocity = T ! Set true to write wall velolcities file
139+
CalcBodyForces = T ! Set true to compute body forces at walls
140+
CalcWallVelocity = T ! Set true to compute velocities at wall boundaries
141+
CalcTimeAverage = F ! Set true to compute time averages
142+
WriteBodyForces = T ! Set true to write bodyforces to file
143+
WriteWallVelocity = T ! Set true to write wall velolcities file

regressioncheck/checks/naca/3D/parameter.ini

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ SpongeBaseFlow = 4 ! Type of baseflow to be used for sponge.
9292
! state, 2: exact function, 3: read baseflow file,
9393
! 4: temporally varying, solution adaptive Pruett
9494
! baseflow
95-
96-
tempFilterWidth = 2 ! Temporal filter witdh used to advance Pruett
97-
! baseflow in time.)
98-
!SpongeBaseflowFile =
95+
96+
tempFilterWidthSponge = 2 ! Temporal filter witdh used to advance Pruett
97+
! baseflow in time.)
98+
99+
BaseFlowRefState = 1 ! Specify which refstate should be used in no baseflowfile is given.
100+
99101
!=========================================================================================
100102
! Riemann
101103
!=========================================================================================

src/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ ENDIF()
6060
# =========================================================================
6161
OPTION(FLEXI_SPLIT_DG "Use split DG formulation" OFF)
6262
CMAKE_DEPENDENT_OPTION(FLEXI_PROLONG_ENTROPY "Prolong on entropy variables" ON
63-
"FLEXI_SPLIT_DG; FLEXI_EQNSYSNAME STREQUAL navierstokes; FLEXI_NODETYPE STREQUAL GAUSS" ON)
63+
"FLEXI_SPLIT_DG; FLEXI_EQNSYSNAME STREQUAL navierstokes; FLEXI_NODETYPE STREQUAL GAUSS" ON)
6464
IF(FLEXI_SPLIT_DG)
6565
ADD_DEFINITIONS(-DSPLIT_DG)
6666
IF((FLEXI_EQNSYSNAME STREQUAL "navierstokes") AND (FLEXI_NODETYPE STREQUAL "GAUSS"))
@@ -329,6 +329,7 @@ FILE(GLOB_RECURSE flexiF90 ./src/interpolation/*.f90
329329
./src/recordpoints/*.f90
330330
./src/restart/*.f90
331331
./src/output/*.f90
332+
./src/baseflow/*.f90
332333
./src/sponge/*.f90
333334
./src/filter/*.f90
334335
./src/io_hdf5/*.f90

src/baseflow/baseflow.f90

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
!=================================================================================================================================
2+
! Copyright (c) 2010-2022 Prof. Claus-Dieter Munz
3+
! Copyright (c) 2022-2024 Prof. Andrea Beck
4+
! This file is part of FLEXI, a high-order accurate framework for numerically solving PDEs with discontinuous Galerkin methods.
5+
! For more information see https://www.flexi-project.org and https://nrg.iag.uni-stuttgart.de/
6+
!
7+
! FLEXI is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
8+
! as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
9+
!
10+
! FLEXI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11+
! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License v3.0 for more details.
12+
!
13+
! You should have received a copy of the GNU General Public License along with FLEXI. If not, see <http://www.gnu.org/licenses/>.
14+
!=================================================================================================================================
15+
#include "flexi.h"
16+
#include "eos.h"
17+
18+
!==================================================================================================================================
19+
!> Subroutines needed for the general base flow based on a moving time average of the instationary flow field, also known as Pruett
20+
!> damping. See "The temporally filtered Navier–Stokes equations: Properties of the residual stress" for details.
21+
!==================================================================================================================================
22+
MODULE MOD_BaseFlow
23+
! MODULES
24+
IMPLICIT NONE
25+
PRIVATE
26+
!----------------------------------------------------------------------------------------------------------------------------------
27+
INTERFACE DefineParametersBaseFlow
28+
MODULE PROCEDURE DefineParametersBaseFlow
29+
END INTERFACE
30+
31+
INTERFACE InitBaseFlow
32+
MODULE PROCEDURE InitBaseFlow
33+
END INTERFACE
34+
35+
INTERFACE UpdateBaseFlow
36+
MODULE PROCEDURE UpdateBaseFlow
37+
END INTERFACE
38+
39+
INTERFACE FinalizeBaseFlow
40+
MODULE PROCEDURE FinalizeBaseFlow
41+
END INTERFACE
42+
43+
PUBLIC :: DefineParametersBaseFlow
44+
PUBLIC :: InitBaseFlow
45+
PUBLIC :: UpdateBaseFlow
46+
PUBLIC :: FinalizeBaseFlow
47+
!==================================================================================================================================
48+
49+
CONTAINS
50+
51+
!==================================================================================================================================
52+
!> Define parameters of basflow to compute a moving time-average during simulation runtime
53+
!==================================================================================================================================
54+
SUBROUTINE DefineParametersBaseFlow()
55+
! MODULES
56+
USE MOD_ReadInTools ,ONLY: prms
57+
! IMPLICIT VARIABLE HANDLING
58+
IMPLICIT NONE
59+
!==================================================================================================================================
60+
CALL prms%SetSection("BaseFlow")
61+
CALL prms%CreateLogicalOption( 'doBaseFlow' ,"Switch on to calculate a baseflow." &
62+
,'.FALSE.')
63+
CALL prms%CreateStringOption( 'BaseFlowFile' ,"FLEXI file (e.g. baseflow, TimeAvg) from which baseflow is read." &
64+
,'none')
65+
CALL prms%CreateIntOption( 'BaseFlowRefState' ,"Specify which refstate should be used in no baseflowfile is given.")
66+
CALL prms%CreateIntArrayOption('SelectiveFilter' ,"Filter Mean to another polynomial degree.",'(/-999,-999,-999/)')
67+
CALL prms%CreateRealOption( 'TimeFilterWidthBaseFlow',"Temporal filter width of exponential, explicit time filter.",'1.0')
68+
END SUBROUTINE DefineParametersBaseFlow
69+
70+
71+
!==================================================================================================================================
72+
!> Perform init of baseflow
73+
!==================================================================================================================================
74+
SUBROUTINE InitBaseFlow()
75+
! MODULES
76+
USE MOD_Globals
77+
USE MOD_PreProc
78+
USE MOD_BaseFlow_Vars
79+
USE MOD_BaseFlow_Filter, ONLY: InitBaseFlowFilter,BaseFlowFilter
80+
USE MOD_BaseFlow_Readin, ONLY: ReadBaseFlow
81+
USE MOD_Equation_Vars, ONLY: RefStateCons
82+
USE MOD_Mesh_Vars, ONLY: nElems
83+
USE MOD_Output_Vars, ONLY: ProjectName
84+
USE MOD_ReadInTools, ONLY: GETSTR,GETINT,GETREAL,GETINTARRAY,GETLOGICAL
85+
USE MOD_Restart_Vars, ONLY: doRestart,RestartTime
86+
USE MOD_StringTools, ONLY: STRICMP
87+
! IMPLICIT VARIABLE HANDLING
88+
IMPLICIT NONE
89+
!----------------------------------------------------------------------------------------------------------------------------------
90+
! INPUT/OUTPUT VARIABLES
91+
!----------------------------------------------------------------------------------------------------------------------------------
92+
! LOCAL VARIABLES
93+
INTEGER :: i,j,k,iElem,BaseFlowRefState
94+
CHARACTER(LEN=255) :: FileName
95+
!==================================================================================================================================
96+
SWRITE(UNIT_stdOut,'(132("-"))')
97+
SWRITE(UNIT_stdOut,'(A)') ' INIT BASEFLOW ...'
98+
99+
! Check if baseflow is switched on, otherwise throw a notification
100+
IF (.NOT. doBaseFlow) doBaseFlow = GETLOGICAL('doBaseFlow')
101+
102+
IF(.NOT. doBaseFlow) THEN
103+
SWRITE(UNIT_stdOut,'(A)') ' | BaseFlow is not computed. Switch on if desired ...'
104+
SWRITE(UNIT_stdOut,'(A)')' INIT BASEFLOW DONE!'
105+
SWRITE(UNIT_stdOut,'(132("-"))')
106+
RETURN
107+
END IF
108+
109+
ALLOCATE(TimeFilterWidthBaseFlow(nElems))
110+
ALLOCATE(fac(nElems))
111+
fac = 0.
112+
TimeFilterWidthBaseFlow = 1./GETREAL("TimeFilterWidthBaseFlow")
113+
BaseFlowFile = GETSTR('BaseFlowFile')
114+
115+
! Check if the previous baseflow file is available
116+
IF (doRestart .AND. STRICMP(TRIM(BaseFlowFile),'none')) THEN
117+
FileName=TRIM(TIMESTAMP(TRIM(ProjectName)//'_BaseFlow',RestartTime))//'.h5'
118+
SWRITE(UNIT_stdOut,'(A,A,A)',ADVANCE='NO') ' | Searching for baseflow file "',TRIM(FileName),'" ...'
119+
IF (FILEEXISTS(FileName)) THEN
120+
BaseFlowFile = FileName
121+
SWRITE(UNIT_stdOut,'(A)',ADVANCE='YES') ' SUCCESS!'
122+
ELSE
123+
SWRITE(UNIT_stdOut,'(A)',ADVANCE='YES') ' FAILED!'
124+
END IF
125+
END IF
126+
127+
ALLOCATE(BaseFlow( PP_nVar,0:PP_N,0:PP_N,0:PP_NZ,nElems))
128+
ALLOCATE(BaseFlowFiltered(PP_nVar,0:PP_N,0:PP_N,0:PP_NZ,nElems))
129+
130+
BaseFlow = 0.
131+
BaseFlowFiltered = 0.
132+
133+
IF (.NOT. (STRICMP(TRIM(BaseFlowFile),'none'))) THEN
134+
CALL ReadBaseFlow(BaseFlowFile)
135+
ELSE
136+
BaseFlowRefState = GETINT('BaseFlowRefState')
137+
DO iElem=1,nElems
138+
DO k=0,PP_NZ; DO j=0,PP_N; DO i=0,PP_N
139+
BaseFlow(:,i,j,k,iElem) = RefStateCons(:,BaseFlowRefState)
140+
END DO; END DO; END DO
141+
END DO
142+
END IF
143+
144+
! Filtering of BaseFlow
145+
BaseFlowFiltered = BaseFlow
146+
CALL InitBaseFlowFilter()
147+
CALL BaseFlowFilter()
148+
149+
InitBaseFlowDone = .TRUE.
150+
SWRITE(UNIT_stdOut,'(A)')' INIT BASEFLOW DONE!'
151+
SWRITE(UNIT_stdOut,'(132("-"))')
152+
153+
END SUBROUTINE InitBaseFlow
154+
155+
156+
!==================================================================================================================================
157+
!>Integrate the Pruett baseflow (time-filtered solution) in time using a simple Euler forward approach:
158+
!>\f$ \frac{d}{dt} \bar{u} \approx \frac{\bar{u}^{n+1} - \bar{u}^{n}}{\Delta t}= \frac{u^n-\bar{u}^n}{\Delta} \f$
159+
!==================================================================================================================================
160+
SUBROUTINE UpdateBaseFlow(dt)
161+
! MODULES
162+
USE MOD_PreProc
163+
USE MOD_BaseFlow_Filter,ONLY: BaseFlowFilter
164+
USE MOD_BaseFlow_Vars
165+
USE MOD_DG_Vars, ONLY: U
166+
USE MOD_Mesh_Vars, ONLY: nElems
167+
! IMPLICIT VARIABLE HANDLING
168+
IMPLICIT NONE
169+
!----------------------------------------------------------------------------------------------------------------------------------
170+
! INPUT/OUTPUT VARIABLES
171+
REAL,INTENT(IN) :: dt !< Current timestep
172+
!----------------------------------------------------------------------------------------------------------------------------------
173+
! LOCAL VARIABLES
174+
INTEGER :: iElem
175+
!==================================================================================================================================
176+
DO iElem=1,nElems
177+
fac(iElem) = MIN(dt*TimeFilterWidthBaseFlow(iElem),1.0)
178+
BaseFlow(:,:,:,:,iElem) = BaseFlow(:,:,:,:,iElem) + (U(:,:,:,:,iElem) - BaseFlow(:,:,:,:,iElem))*fac(iElem)
179+
END DO ! iElem
180+
181+
! Selective Filter
182+
BaseFlowFiltered = BaseFlow
183+
CALL BaseFlowFilter()
184+
185+
END SUBROUTINE UpdateBaseFlow
186+
187+
!==================================================================================================================================
188+
!> Finalizes variables necessary for baseflow.
189+
!==================================================================================================================================
190+
SUBROUTINE FinalizeBaseFlow()
191+
! MODULES
192+
USE MOD_BaseFlow_Vars
193+
! IMPLICIT VARIABLE HANDLING
194+
IMPLICIT NONE
195+
!----------------------------------------------------------------------------------------------------------------------------------
196+
! LOCAL VARIABLES
197+
!==================================================================================================================================
198+
SDEALLOCATE(BaseFlow)
199+
SDEALLOCATE(BaseFlowFiltered)
200+
SDEALLOCATE(TimeFilterWidthBaseFlow)
201+
SDEALLOCATE(fac)
202+
SDEALLOCATE(SelectiveFilterMatrix)
203+
END SUBROUTINE FinalizeBaseFlow
204+
205+
END MODULE MOD_BaseFlow

0 commit comments

Comments
 (0)