Skip to content

Commit b241433

Browse files
authored
Merge pull request #267 from loganoz/david_development
Adaptive time step
2 parents be6d065 + 800f183 commit b241433

32 files changed

Lines changed: 61305 additions & 113 deletions

.github/workflows/CI_parallel.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,23 @@ jobs:
930930
mpiexec -n 64 ./horses3d.ns Actuator.control
931931
if: '!cancelled()'
932932

933+
#
934+
# 33) Cylinder with Adaptive Time Step and Reinforcement Learning p-adaptation
935+
# --------------------------------------------
936+
- name: Build Cylinder_AdaptiveTimeStep_pAdaptationRL
937+
working-directory: ./Solver/test/NavierStokes/Cylinder_AdaptiveTimeStep_pAdaptationRL/SETUP
938+
run: |
939+
source /opt/intel/oneapi/setvars.sh || true
940+
make MODE=${{matrix.mode}} COMPILER=${{matrix.compiler}} COMM=${{matrix.comm}} ENABLE_THREADS=${{matrix.enable_threads}} WITH_METIS=YES
941+
if: '!cancelled()'
942+
943+
- name: Run Cylinder_AdaptiveTimeStep_pAdaptationRL
944+
working-directory: ./Solver/test/NavierStokes/Cylinder_AdaptiveTimeStep_pAdaptationRL
945+
run: |
946+
source /opt/intel/oneapi/setvars.sh || true
947+
mpiexec -n 64 ./horses3d.ns Cylinder_AdaptiveTimeStep_pAdaptationRL.control
948+
if: '!cancelled()'
949+
933950
########################################################################
934951
####### PARTICLES ########
935952
########################################################################

.github/workflows/CI_sequential 2.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,3 +786,21 @@ jobs:
786786
./horses3d.ns Actuator.control
787787
if: '!cancelled()'
788788

789+
#
790+
# 33) Cylinder with Adaptive Time Step and Reinforcement Learning p-adaptation
791+
# --------------------------------------------
792+
793+
- name: Build Cylinder_AdaptiveTimeStep_pAdaptationRL
794+
working-directory: ./Solver/test/NavierStokes/Cylinder_AdaptiveTimeStep_pAdaptationRL/SETUP
795+
run: |
796+
source /opt/intel/oneapi/setvars.sh || true
797+
make MODE=${{matrix.mode}} COMPILER=${{matrix.compiler}} COMM=${{matrix.comm}} ENABLE_THREADS=${{matrix.enable_threads}} WITH_MKL=${{matrix.mkl}} WITH_HDF5=${{matrix.hdf5}}
798+
if: '!cancelled()'
799+
800+
- name: Run Cylinder_AdaptiveTimeStep_pAdaptationRL
801+
working-directory: ./Solver/test/NavierStokes/Cylinder_AdaptiveTimeStep_pAdaptationRL
802+
run: |
803+
source /opt/intel/oneapi/setvars.sh || true
804+
./horses3d.ns Cylinder_AdaptiveTimeStep_pAdaptationRL.control
805+
if: '!cancelled()'
806+

Solver/configure

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ TEST_CASES="./Euler/BoxAroundCircle \
7878
./NavierStokes/VirtualSurfaces_acoustics_pAdaptationRL \
7979
./NavierStokes/ActuatorLineInterpolation \
8080
./NavierStokes/ActuatorLineProjection \
81+
./NavierStokes/Cylinder_AdaptiveTimeStep_pAdaptationRL \
8182
./IncompressibleNS/Convergence \
8283
./IncompressibleNS/Kovasznay \
8384
./IncompressibleNS/TaylorGreen \

Solver/src/libs/mesh/HexMesh.f90

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5677,5 +5677,12 @@ subroutine HexMesh_DefineAcousticElements(self, observer, acoustic_sources, d_th
56775677
call acousticElementList % destruct
56785678
call aerodynamicElementList % destruct
56795679

5680+
safedeallocate(x)
5681+
safedeallocate(y)
5682+
safedeallocate(z)
5683+
safedeallocate(total_x)
5684+
safedeallocate(total_y)
5685+
safedeallocate(total_z)
5686+
56805687
end subroutine HexMesh_DefineAcousticElements
56815688
END MODULE HexMeshClass

Solver/src/libs/mesh/StorageClass.f90

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ module StorageClass
7979
real(kind=RP), allocatable :: S_NSP(:,:,:,:) ! NSE Particles source term
8080
real(kind=RP), allocatable :: QbaseSponge(:,:,:,:) ! Base Flow State vector for sponges
8181
real(kind=RP), allocatable :: intensitySponge(:,:,:) ! Intensity for sponges
82+
real(kind=RP), allocatable :: QLowRK(:,:,:,:) ! NSE State vector solved with a lower order RK method (required for adaptive time-stepping)
8283
#ifndef ACOUSTIC
8384
real(kind=RP), allocatable :: mu_NS(:,:,:,:) ! (mu, beta, kappa) artificial
8485
real(kind=RP), allocatable :: mu_turb_NS(:,:,:) ! mu of LES
@@ -791,6 +792,7 @@ elemental subroutine ElementStorage_Construct(self, Nx, Ny, Nz, computeGradients
791792
!
792793
#ifdef FLOW
793794
allocate ( self % QNS (1:NCONS,0:Nx,0:Ny,0:Nz) )
795+
allocate ( self % QLowRK(1:NCONS,0:Nx,0:Ny,0:Nz) )
794796
allocate (self % QbaseSponge(1:NCONS,0:Nx,0:Ny,0:Nz) )
795797
allocate (self % intensitySponge(0:Nx,0:Ny,0:Nz) )
796798
allocate ( self % QdotNS(1:NCONS,0:Nx,0:Ny,0:Nz) )
@@ -877,6 +879,7 @@ elemental subroutine ElementStorage_Construct(self, Nx, Ny, Nz, computeGradients
877879
self % S_NS = 0.0_RP
878880
self % S_NSP = 0.0_RP
879881
self % QNS = 0.0_RP
882+
self % QLowRK = 0.0_RP
880883
self % QbaseSponge = 0.0_RP
881884
self % intensitySponge = 0.0_RP
882885
self % QDotNS = 0.0_RP
@@ -980,6 +983,7 @@ elemental subroutine ElementStorage_Assign(to, from)
980983

981984
#ifdef FLOW
982985
to % QNS = from % QNS
986+
to % QLowRK = from % QLowRK
983987
to % QbaseSponge = from % QbaseSponge
984988
to % intensitySponge = from % intensitySponge
985989

@@ -1076,6 +1080,7 @@ elemental subroutine ElementStorage_Destruct(self)
10761080
safedeallocate(self % QDotNS)
10771081
safedeallocate(self % QbaseSponge)
10781082
safedeallocate(self % intensitySponge)
1083+
safedeallocate(self % QLowRK)
10791084

10801085
if ( allocated(self % PrevQ) ) then
10811086
num_prevSol = size(self % PrevQ)
@@ -1109,6 +1114,9 @@ elemental subroutine ElementStorage_Destruct(self)
11091114
!if (self % anJacobian) then ! Not needed since there's only one variable (= one if)
11101115
safedeallocate(self % dF_dgradQ)
11111116
!end if
1117+
1118+
! Destruct statistics
1119+
call self % stats % destruct()
11121120
#endif
11131121

11141122
#ifdef CAHNHILLIARD
@@ -1139,6 +1147,18 @@ elemental subroutine ElementStorage_Destruct(self)
11391147

11401148
safedeallocate(self % PrevQ)
11411149

1150+
! Deallocate RKSteps
1151+
! ------------------
1152+
#ifdef MULTIPHASE
1153+
if ( allocated(self % RKSteps) ) then
1154+
do k = 1, size(self % RKSteps)
1155+
safedeallocate(self % RKSteps(k) % K)
1156+
safedeallocate(self % RKSteps(k) % hatK)
1157+
end do
1158+
deallocate(self % RKSteps)
1159+
end if
1160+
#endif
1161+
11421162
end subroutine ElementStorage_Destruct
11431163
#ifdef FLOW
11441164
pure subroutine ElementStorage_SetStorageToNS(self)
@@ -1271,6 +1291,7 @@ impure elemental subroutine ElementStorage_InterpolateSolution(this,other,nodes,
12711291
if (all(this % Nxyz == other % Nxyz)) then
12721292
other % Q = this % Q
12731293
other % QbaseSponge = this % QbaseSponge
1294+
other % QLowRK = this % QLowRK
12741295
else
12751296
!$omp critical
12761297
call NodalStorage(this % Nxyz(1)) % construct(nodes,this % Nxyz(1))
@@ -1319,6 +1340,15 @@ impure elemental subroutine ElementStorage_InterpolateSolution(this,other,nodes,
13191340
this % Q(1:,0:,0:,0:) => this % QbaseSponge
13201341
other % Q(1:,0:,0:,0:) => other % QbaseSponge
13211342

1343+
call Interp3DArrays (Nvars = NCONS , &
1344+
Nin = this % Nxyz , &
1345+
inArray = this % Q , &
1346+
Nout = other % Nxyz , &
1347+
outArray = other % Q )
1348+
1349+
this % Q(1:,0:,0:,0:) => this % QLowRK
1350+
other % Q(1:,0:,0:,0:) => other % QLowRK
1351+
13221352
call Interp3DArrays (Nvars = NCONS , &
13231353
Nin = this % Nxyz , &
13241354
inArray = this % Q , &
@@ -1763,9 +1793,9 @@ subroutine Statistics_Construct(self, no_of_variables, N)
17631793

17641794
end subroutine Statistics_Construct
17651795

1766-
subroutine Statistics_Destruct(self)
1796+
pure subroutine Statistics_Destruct(self)
17671797
implicit none
1768-
class(Statistics_t) :: self
1798+
class(Statistics_t), intent(inout) :: self
17691799

17701800
safedeallocate( self % data )
17711801

0 commit comments

Comments
 (0)