|
| 1 | +! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! |
| 2 | +! |
| 3 | +! Maintainers : support@fluidnumerics.com |
| 4 | +! Official Repository : https://github.com/FluidNumerics/self/ |
| 5 | +! |
| 6 | +! Copyright © 2024 Fluid Numerics LLC |
| 7 | +! |
| 8 | +! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: |
| 9 | +! |
| 10 | +! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. |
| 11 | +! |
| 12 | +! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in |
| 13 | +! the documentation and/or other materials provided with the distribution. |
| 14 | +! |
| 15 | +! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from |
| 16 | +! this software without specific prior written permission. |
| 17 | +! |
| 18 | +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 | +! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | +! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 21 | +! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 22 | +! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 | +! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | +! |
| 25 | +! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! |
| 26 | + |
| 27 | +program Euler_Example |
| 28 | + |
| 29 | + use self_data |
| 30 | + use self_Euler2D |
| 31 | + |
| 32 | + implicit none |
| 33 | + |
| 34 | + ! Adapted from https://github.com/trixi-framework/Trixi.jl/blob/main/src/equations/compressible_euler_2d.jl#L157 |
| 35 | + ! A weak blast wave taken from |
| 36 | + ! - Sebastian Hennemann, Gregor J. Gassner (2020) |
| 37 | + ! A provably entropy stable subcell shock capturing approach for high order split form DG |
| 38 | + ! [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) |
| 39 | + real(prec),parameter :: rho0 = 1.225_prec |
| 40 | + real(prec),parameter :: rhoprime = 0.1_prec |
| 41 | + real(prec),parameter :: Lr = 75.0_prec |
| 42 | + real(prec),parameter :: P0 = 101325.0_prec ! 1 atm |
| 43 | + real(prec),parameter :: Eprime = 35900.0_prec |
| 44 | + real(prec),parameter :: Le = 50.0_prec |
| 45 | + real(prec),parameter :: x0 = 250.0_prec |
| 46 | + real(prec),parameter :: y0 = 250.0_prec |
| 47 | + real(prec),parameter :: nu = 1.020408163_prec ! Viscosity |
| 48 | + real(prec),parameter :: kappa = 1.020408163_prec ! Thermal diffusivity (Pr = 1) |
| 49 | + ! Grid parameters |
| 50 | + real(prec),parameter :: dx = 5.0_prec ! Grid spacing in the x-direction |
| 51 | + real(prec),parameter :: dy = 5.0_prec ! Grid spacing in the y-direction |
| 52 | + integer,parameter :: ny = 50 ! Number of x grid points per tile |
| 53 | + integer,parameter :: nx = 50 ! Number of y grid points per tile |
| 54 | + integer,parameter :: nTx = 2 ! Number of tiles in the x-direction |
| 55 | + integer,parameter :: nTy = 2 ! Number of tiles in the y-direction |
| 56 | + |
| 57 | + character(SELF_INTEGRATOR_LENGTH),parameter :: integrator = 'rk3' |
| 58 | + integer,parameter :: controlDegree = 7 |
| 59 | + integer,parameter :: targetDegree = 15 |
| 60 | + real(prec),parameter :: dt = 10.0_prec**(-4) ! time-step size |
| 61 | + real(prec),parameter :: endtime = 10.0_prec**(-2) ! end time |
| 62 | + real(prec),parameter :: iointerval = 10.0_prec**(-3) |
| 63 | + real(prec) :: e0,ef ! Initial and final entropy |
| 64 | + type(Euler2D) :: modelobj |
| 65 | + type(Lagrange),target :: interp |
| 66 | + type(Mesh2D),target :: mesh |
| 67 | + type(SEMQuad),target :: geometry |
| 68 | + integer :: bcids(1:4) |
| 69 | + |
| 70 | + ! Create a structured mesh |
| 71 | + bcids(1:4) = [SELF_BC_NONORMALFLOW, & ! South |
| 72 | + SELF_BC_NONORMALFLOW, & ! East |
| 73 | + SELF_BC_NONORMALFLOW, & ! North |
| 74 | + SELF_BC_NONORMALFLOW] ! West |
| 75 | + |
| 76 | + call mesh%StructuredMesh(nx,ny,nTx,nTy,dx,dy,bcids) |
| 77 | + |
| 78 | + ! Create an interpolant |
| 79 | + call interp%Init(N=controlDegree, & |
| 80 | + controlNodeType=GAUSS, & |
| 81 | + M=targetDegree, & |
| 82 | + targetNodeType=UNIFORM) |
| 83 | + |
| 84 | + ! Generate geometry (metric terms) from the mesh elements |
| 85 | + call geometry%Init(interp,mesh%nElem) |
| 86 | + call geometry%GenerateFromMesh(mesh) |
| 87 | + |
| 88 | + ! Initialize the model |
| 89 | + call modelobj%Init(mesh,geometry) |
| 90 | + modelobj%prescribed_bcs_enabled = .false. ! Disables prescribed boundary condition block for gpu accelerated implementations |
| 91 | + modelobj%tecplot_enabled = .false. ! Disable tecplot output |
| 92 | + modelobj%primitive_gradient_enabled = .true. ! Enable primitive gradient calculation for momentum and energy diffusion |
| 93 | + |
| 94 | + ! Set up blast wave initial conditions |
| 95 | + call modelobj%ThermalBubble(rho0,rhoprime,Lr,P0,Eprime,Le,x0,y0) |
| 96 | + |
| 97 | + call modelobj%WriteModel() |
| 98 | + call modelobj%IncrementIOCounter() |
| 99 | + |
| 100 | + call modelobj%CalculateEntropy() |
| 101 | + call modelobj%ReportEntropy() |
| 102 | + e0 = modelobj%entropy |
| 103 | + ! Set the model's time integration method |
| 104 | + call modelobj%SetTimeIntegrator(integrator) |
| 105 | + |
| 106 | + ! forward step the model to `endtime` using a time step |
| 107 | + ! of `dt` and outputing model data every `iointerval` |
| 108 | + call modelobj%ForwardStep(endtime,dt,iointerval) |
| 109 | + |
| 110 | + ef = modelobj%entropy |
| 111 | + |
| 112 | + if(ef > e0) then |
| 113 | + print*,"Error: Final absmax greater than initial absmax! ",e0,ef |
| 114 | + stop 1 |
| 115 | + endif |
| 116 | + ! Clean up |
| 117 | + call modelobj%free() |
| 118 | + call mesh%free() |
| 119 | + call geometry%free() |
| 120 | + call interp%free() |
| 121 | + |
| 122 | +endprogram Euler_Example |
0 commit comments