Skip to content

Commit

Permalink
Add tests for default boundary conditions via null model
Browse files Browse the repository at this point in the history
Also removed unused function for converting boundary condition
characters to integer flags

These changes are made to improve the diff hit on PR #59
  • Loading branch information
fluidnumerics-joe committed Oct 5, 2024
1 parent aa69df1 commit 3be2b7a
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 46 deletions.
13 changes: 13 additions & 0 deletions src/SELF_Mesh.f90
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,17 @@ module SELF_Mesh
integer,parameter :: SELF_MESH_HOPR_2D = 3
integer,parameter :: SELF_MESH_HOPR_3D = 4

! //////////////////////////////////////////////// !
! Boundary Condition parameters
!

! Conditions on the solution
integer,parameter :: SELF_BC_PRESCRIBED = 100
integer,parameter :: SELF_BC_RADIATION = 101
integer,parameter :: SELF_BC_NONORMALFLOW = 102

! Conditions on the solution gradients
integer,parameter :: SELF_BC_PRESCRIBED_STRESS = 200
integer,parameter :: SELF_BC_NOSTRESS = 201

endmodule SELF_Mesh
46 changes: 1 addition & 45 deletions src/SELF_Model.f90
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,6 @@ module SELF_Model
integer,parameter :: SELF_INTEGRATOR_LENGTH = 10 ! max length of integrator methods when specified as char
integer,parameter :: SELF_EQUATION_LENGTH = 500

! //////////////////////////////////////////////// !
! Boundary Condition parameters
!

! Conditions on the solution
integer,parameter :: SELF_BC_PRESCRIBED = 100
integer,parameter :: SELF_BC_RADIATION = 101
integer,parameter :: SELF_BC_NONORMALFLOW = 102

! Conditions on the solution gradients
integer,parameter :: SELF_BC_PRESCRIBED_STRESS = 200
integer,parameter :: SELF_BC_NOSTRESS = 201

! //////////////////////////////////////////////// !
! Model Formulations
!
Expand Down Expand Up @@ -274,42 +261,11 @@ subroutine IncrementIOCounter(this)

endsubroutine IncrementIOCounter

function GetBCFlagForChar(charFlag) result(intFlag)
!! This method is used to return the integer flag from a char for boundary conditions
!!
implicit none
character(*),intent(in) :: charFlag
integer :: intFlag

select case(UpperCase(trim(charFlag)))

case("PRESCRIBED")
intFlag = SELF_BC_PRESCRIBED

case("RADIATION")
intFlag = SELF_BC_RADIATION

case("NO_NORMAL_FLOW")
intFlag = SELF_BC_NONORMALFLOW

case("PRESCRIBED_STRESS")
intFlag = SELF_BC_PRESCRIBED_STRESS

case("NO_STRESS")
intFlag = SELF_BC_NOSTRESS

case DEFAULT
intFlag = 0

endselect

endfunction GetBCFlagForChar

subroutine PrintType_Model(this)
implicit none
class(Model),intent(in) :: this

print*,__FILE__//" : No model type"
print*,__FILE__//" : Model : No model type"

endsubroutine PrintType_Model

Expand Down
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ add_fortran_tests (
"mappedvectordgdivergence_3d_linear_sideexchange.f90"
"nulldgmodel1d.f90"
"nulldgmodel2d.f90"
"nulldgmodel2d_prescribed.f90"
"nulldgmodel3d.f90"
"nulldgmodel3d_prescribed.f90"
"advection_diffusion_1d_euler.f90"
"advection_diffusion_1d_euler_pickup.f90"
"advection_diffusion_1d_rk2.f90"
Expand Down
1 change: 1 addition & 0 deletions test/nulldgmodel1d.f90
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ program NullDGModel1D_euler

! Initialize the model
call modelobj%Init(nvar,mesh,geometry)
call modelobj%PrintType()
! Set the initial condition
call modelobj%solution%SetEquation(1,'f = 0.0 )')
call modelobj%solution%SetInteriorFromEquation(0.0_prec)
Expand Down
3 changes: 2 additions & 1 deletion test/nulldgmodel2d.f90
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ program NullDGModel2D_euler
! Create a uniform block mesh
call get_environment_variable("WORKSPACE",WORKSPACE)
call mesh%Read_HOPr(trim(WORKSPACE)//"/share/mesh/Block2D/Block2D_mesh.h5")

call mesh%ResetBoundaryConditionType(SELF_BC_NONORMALFLOW)
! Create an interpolant
call interp%Init(N=controlDegree, &
controlNodeType=GAUSS, &
Expand All @@ -62,6 +62,7 @@ program NullDGModel2D_euler

! Initialize the model
call modelobj%Init(nvar,mesh,geometry)
call modelobj%gradient_enabled = .true.

! Set the initial condition
call modelobj%solution%SetEquation(1,'f = 0.0')
Expand Down
2 changes: 2 additions & 0 deletions test/nulldgmodel3d.f90
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ program NullDGModel3D_euler
! Create a uniform block mesh
call get_environment_variable("WORKSPACE",WORKSPACE)
call mesh%Read_HOPr(trim(WORKSPACE)//"/share/mesh/Block3D/Block3D_mesh.h5")
call mesh%ResetBoundaryConditionType(SELF_BC_NONORMALFLOW)

! Create an interpolant
call interp%Init(N=controlDegree, &
Expand All @@ -59,6 +60,7 @@ program NullDGModel3D_euler

! Initialize the model
call modelobj%Init(nvar,mesh,geometry)
call modelobj%gradient_enabled = .true.

! Set the initial condition
call modelobj%solution%SetEquation(1,'f = 0.0')
Expand Down
89 changes: 89 additions & 0 deletions test/nulldgmodel3d_prescribed.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// !
!
! Maintainers : [email protected]
! Official Repository : https://github.com/FluidNumerics/self/
!
! Copyright © 2024 Fluid Numerics LLC
!
! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
!
! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
!
! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in
! the documentation and/or other materials provided with the distribution.
!
! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from
! this software without specific prior written permission.
!
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!
! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// !

program NullDGModel3D_euler

use self_data
use self_NullDGModel3D

implicit none
character(SELF_INTEGRATOR_LENGTH),parameter :: integrator = 'euler'
integer,parameter :: nvar = 1
integer,parameter :: controlDegree = 7
integer,parameter :: targetDegree = 16
real(prec),parameter :: dt = 1.0_prec
real(prec),parameter :: endtime = 1.0_prec
real(prec),parameter :: iointerval = 1.0_prec
type(NullDGModel3D) :: modelobj
type(Lagrange),target :: interp
type(Mesh3D),target :: mesh
type(SEMHex),target :: geometry
character(LEN=255) :: WORKSPACE

! Create a uniform block mesh
call get_environment_variable("WORKSPACE",WORKSPACE)
call mesh%Read_HOPr(trim(WORKSPACE)//"/share/mesh/Block3D/Block3D_mesh.h5")
call mesh%ResetBoundaryConditionType(SELF_BC_PRESCRIBED)

! Create an interpolant
call interp%Init(N=controlDegree, &
controlNodeType=GAUSS, &
M=targetDegree, &
targetNodeType=UNIFORM)

! Generate geometry (metric terms) from the mesh elements
call geometry%Init(interp,mesh%nElem)
call geometry%GenerateFromMesh(mesh)

! Initialize the model
call modelobj%Init(nvar,mesh,geometry)
call modelobj%gradient_enabled = .true.
! Set the initial condition
call modelobj%solution%SetEquation(1,'f = 0.0')
call modelobj%solution%SetInteriorFromEquation(geometry,0.0_prec)

print*,"min, max (interior)", &
minval(modelobj%solution%interior), &
maxval(modelobj%solution%interior)

! Set the model's time integration method
call modelobj%SetTimeIntegrator(integrator)

! forward step the model to `endtime` using a time step
! of `dt` and outputing model data every `iointerval`
call modelobj%ForwardStep(endtime,dt,iointerval)

print*,"min, max (interior)", &
minval(modelobj%solution%interior), &
maxval(modelobj%solution%interior)

! Clean up
call modelobj%free()
call mesh%free()
call geometry%free()
call interp%free()

endprogram NullDGModel3D_euler

0 comments on commit 3be2b7a

Please sign in to comment.