Linear Euler (2D)#
Definition#
The SELF_LinearEuler2D_t
module defines the LinearEuler2D_t
class. In SELF, models are posed in the form of a generic conservation law
where \(\vec{s}\) is a vector of solution variables, \(\overleftrightarrow{f}\) is the conservative flux, and \(\vec{q}\) are non-conservative source terms.
For the Linear Euler equations in 2-D
where \(\rho\) is a density anomaly, referenced to the density \(\rho_0\), \(u\) and \(v\) are the \(x\) and \(y\) components of the fluid velocity (respectively), and \(p\) is the pressure. When we assume an ideal gas, and a motionless background state, the conservative fluxes are
where \(c\) is the (constant) speed of sound. The source term is set to zero.
To track stability of the Euler equation, the total entropy function is
Implementation#
The Linear Euler 2D model is implemented as a type extension of the DGModel2D
class. The LinearEuler2D_t
class adds parameters for the reference density and the speed speed of sound and overrides the SetMetadata
, entropy_func
, flux2d
, and riemannflux2d
type-bound procedures.
Riemann Solver#
The LinearEuler2D
class is defined using the conservative form of the conservation law. The Riemman solver for the hyperbolic part of Euler equation is the local Lax Friedrichs upwind riemann solver
where
The details for this implementation can be found in self_lineareuler2d_t.f90
Boundary conditions#
When initializing the mesh for your Euler 2D equation solver, you can change the boundary conditions to
SELF_BC_Radiation
to set the external state on model boundaries to 0 in the Riemann solverSELF_BC_NoNormalFlow
to set the external normal velocity to the negative of the interior normal velocity and prolong the density, pressure, and tangential velocity (free slip). This effectively creates a reflecting boundary condition.SELF_BC_Prescribed
to set a prescribed external state.
As an example, when using the built-in structured mesh generator, you can do the following
type(Mesh2D),target :: mesh
integer :: bcids(1:4)
bcids(1:4) = (/&
SELF_NONORMALFLOW,& ! South boundary condition
SELF_RADIATION,& ! East boundary condition
SELF_PRESCRIBED,& ! North boundary condition
SELF_RADIATION & ! West boundary condition
/)
call mesh%StructuredMesh(nxPerTile=5,nyPerTile=5,&
nTileX=2,nTileY=2,&
dx=0.1_prec,dy=0.1_prec,bcids)
Note
See the Structured Mesh documentation for details on using the structuredmesh
procedure
Note
To set a prescribed state as a function of position and time, you can create a type-extension of the LinearEuler2D
class and override the hbc2d_Prescribed
GPU Acceleration#
When building SELF with GPU acceleration enabled, the Linear Euler (2-D) model overrides the following DGModel2D
type-bound procedures
BoundaryFlux
FluxMethod
SourceMethod
SetBoundaryCondition
SetGradientBoundaryCondition
These methods are one-level above the usual pure function
type-bound procedures used to define the riemann solver, flux, source terms, and boundary conditions. These procedures need to be overridden with calls to GPU accelerated kernels to make the solver fully resident on the GPU.
Out-of-the-box, the no-normal-flow and radiation boundary conditions are GPU accelerated. However, prescribed boundary conditions are CPU-only. We have opted to keep the prescribed boundary conditions CPU-only so that their implementation remains easy-to-use. This implies that some data is copied between host and device every iteration when prescribed boundary conditions are enabled.
Note
In simulations where no prescribed boundaries are used, or your prescribed boundaries are time independent, you can disable prescribed boundary conditions by explicitly setting modelobj % prescribed_bcs_enabled = .false.
. This can improve the time-to-solution for your simulation by avoiding unnecessary host-device memory movement. An example of this feature is shown in examples/lineareuler2d_spherical_soundwave_closeddomain.f90
Example usage#
For examples, see any of the following
examples/lineareuler2d_spherical_soundwave_closeddomain.f90
- Implements a simulation with a gaussian pressure and density anomaly as an initial condition in a domain with no normal flow boundary conditions on all sides.examples/linear_euler2d_planewave_propagation.f90
- Implements a simulation with a gaussian plane wave that propagates at a \(45^\circ\) angle through a square domain. The initial and boundary conditions are all taken as an exact plane wave solution to the Linear Euler equations in 2D. This provides an example for using prescribed boundary conditions.examples/linear_euler2d_planewave_reflection.f90
- Implements a simulation with a gaussian plane wave that propagates at a \(45^\circ\) angle through a square domain and reflects off a wall at x=1 (eastern domain boundary). The initial and boundary conditions are all taken as an exact plane wave solution to the Linear Euler equations in 2D derived using the method of images. This provides an example for using prescribed boundary conditions in combination with the no-normal-flow boundary conditions.