-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gravitational acceleration through environmentals attribute
- Loading branch information
1 parent
e04fa5e
commit 833efd6
Showing
4 changed files
with
246 additions
and
9 deletions.
There are no files selected for viewing
File renamed without changes.
141 changes: 141 additions & 0 deletions
141
examples/CompressibleIdealGas2D/HydrostaticAdjustment.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
PROGRAM HydrostaticAdjustment | ||
|
||
USE SELF_Constants | ||
USE SELF_Lagrange | ||
USE SELF_Mesh | ||
USE SELF_Geometry | ||
USE SELF_CLI | ||
USE SELF_CompressibleIdealGas2D | ||
|
||
IMPLICIT NONE | ||
|
||
INTEGER, PARAMETER :: nvar = 4 ! The number prognostic variables | ||
|
||
REAL(prec) :: dt | ||
REAL(prec) :: ioInterval | ||
REAL(prec) :: tn | ||
INTEGER :: N ! Control Degree | ||
INTEGER :: M ! Target degree | ||
INTEGER :: quadrature | ||
CHARACTER(LEN=self_QuadratureTypeCharLength) :: qChar | ||
CHARACTER(LEN=self_QuadratureTypeCharLength) :: integrator | ||
LOGICAL :: mpiRequested | ||
LOGICAL :: gpuRequested | ||
|
||
REAL(prec) :: referenceEntropy | ||
TYPE(Lagrange),TARGET :: interp | ||
TYPE(Mesh2D),TARGET :: mesh | ||
TYPE(SEMQuad),TARGET :: geometry | ||
TYPE(CompressibleIdealGas2D),TARGET :: semModel | ||
TYPE(MPILayer),TARGET :: decomp | ||
TYPE(CLI) :: args | ||
CHARACTER(LEN=255) :: SELF_PREFIX | ||
CHARACTER(LEN=500) :: meshfile | ||
CHARACTER(LEN=100) :: gravity | ||
|
||
|
||
CALL get_environment_variable("SELF_PREFIX", SELF_PREFIX) | ||
CALL args % Init( TRIM(SELF_PREFIX)//"/etc/cli/default.json") | ||
CALL args % LoadFromCLI() | ||
|
||
CALL args % Get_CLI('--output-interval',ioInterval) | ||
CALL args % Get_CLI('--end-time',tn) | ||
CALL args % Get_CLI('--time-step',dt) | ||
CALL args % Get_CLI('--mpi',mpiRequested) | ||
CALL args % Get_CLI('--gpu',gpuRequested) | ||
CALL args % Get_CLI('--control-degree',N) | ||
CALL args % Get_CLI('--control-quadrature',qChar) | ||
quadrature = GetIntForChar(qChar) | ||
CALL args % Get_CLI('--target-degree',M) | ||
CALL args % Get_CLI('--integrator',integrator) | ||
CALL args % Get_CLI('--mesh',meshfile) | ||
|
||
IF( TRIM(meshfile) == '')THEN | ||
meshfile = TRIM(SELF_PREFIX)//"/etc/mesh/Block2D/Block2D_mesh.h5" | ||
ENDIF | ||
|
||
! Initialize a domain decomposition | ||
! Here MPI is disabled, since scaling is currently | ||
! atrocious with the uniform block mesh | ||
CALL decomp % Init(enableMPI=mpiRequested) | ||
|
||
! Create an interpolant | ||
CALL interp % Init(N,quadrature,M,UNIFORM) | ||
|
||
! Read in mesh file | ||
CALL mesh % Read_HOPr(TRIM(meshfile),decomp) | ||
|
||
! Reset the boundary condition to prescribed | ||
CALL mesh % ResetBoundaryConditionType(SELF_BC_NONORMALFLOW) | ||
|
||
! Generate geometry (metric terms) from the mesh elements | ||
CALL geometry % Init(interp,mesh % nElem) | ||
CALL geometry % GenerateFromMesh(mesh) | ||
|
||
! Initialize the semModel | ||
CALL semModel % Init(nvar,mesh,geometry,decomp) | ||
|
||
IF( gpuRequested )THEN | ||
CALL semModel % EnableGPUAccel() | ||
! Update the device for the whole model | ||
! This ensures that the mesh, geometry, and default state match on the GPU | ||
CALL semModel % UpdateDevice() | ||
ENDIF | ||
|
||
CALL semModel % SetStaticSTP() | ||
CALL semModel % CalculateEntropy() | ||
CALL semModel % ReportEntropy() | ||
referenceEntropy = semModel % entropy | ||
|
||
! Uses the initial condition to set the prescribed state | ||
! for model boundary conditions | ||
CALL semModel % SetPrescribedSolution() | ||
|
||
CALL semModel % SetGravity( "p = 10.0*y" ) | ||
|
||
! Write the initial condition to file | ||
CALL semModel % WriteModel() | ||
CALL semModel % WriteTecplot() | ||
|
||
! Set the time integrator | ||
CALL semModel % SetTimeIntegrator(TRIM(integrator)) | ||
|
||
! Set your time step | ||
semModel % dt = dt | ||
|
||
!! Forward step the semModel and do the file io | ||
CALL semModel % ForwardStep( tn = tn, ioInterval = ioInterval ) | ||
|
||
!! Manually write the last semModel state | ||
CALL semModel % WriteModel('solution.pickup.h5') | ||
|
||
! Error checking ! | ||
IF( semModel % entropy /= semModel % entropy )THEN | ||
PRINT*, "Model entropy is not a number" | ||
STOP 2 | ||
ENDIF | ||
|
||
IF( semModel % entropy >= HUGE(1.0_prec) )THEN | ||
PRINT*, "Model entropy is infinite." | ||
STOP 1 | ||
ENDIF | ||
|
||
IF( semModel % entropy > referenceEntropy )THEN | ||
PRINT*, "Warning : final entropy greater than initial entropy" | ||
! Currently do nothing in this situation, since | ||
! conservative solvers in mapped geometries may | ||
! not be entropy conservative. | ||
! However, throwing this warning will bring some | ||
! visibility | ||
ENDIF | ||
|
||
! Clean up | ||
CALL semModel % Free() | ||
CALL decomp % Free() | ||
CALL geometry % Free() | ||
CALL mesh % Free() | ||
CALL interp % Free() | ||
CALL args % Free() | ||
CALL decomp % Finalize() | ||
|
||
END PROGRAM HydrostaticAdjustment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters