diff --git a/src/SELF_Mesh.f90 b/src/SELF_Mesh.f90 index 7f3cf0656..c886e33fd 100644 --- a/src/SELF_Mesh.f90 +++ b/src/SELF_Mesh.f90 @@ -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 diff --git a/src/SELF_Model.f90 b/src/SELF_Model.f90 index 1777cf854..f36d53a04 100644 --- a/src/SELF_Model.f90 +++ b/src/SELF_Model.f90 @@ -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 ! @@ -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 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 557544fbb..121f63ad4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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" diff --git a/test/nulldgmodel1d.f90 b/test/nulldgmodel1d.f90 index 10064495e..07e40d6e7 100644 --- a/test/nulldgmodel1d.f90 +++ b/test/nulldgmodel1d.f90 @@ -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) diff --git a/test/nulldgmodel2d.f90 b/test/nulldgmodel2d.f90 index 1a74a6129..6b6e97e48 100644 --- a/test/nulldgmodel2d.f90 +++ b/test/nulldgmodel2d.f90 @@ -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, & @@ -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') diff --git a/test/nulldgmodel3d.f90 b/test/nulldgmodel3d.f90 index d575ea0c1..3ab8e7c45 100644 --- a/test/nulldgmodel3d.f90 +++ b/test/nulldgmodel3d.f90 @@ -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, & @@ -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') diff --git a/test/nulldgmodel3d_prescribed.f90 b/test/nulldgmodel3d_prescribed.f90 new file mode 100644 index 000000000..cd1e1d8fd --- /dev/null +++ b/test/nulldgmodel3d_prescribed.f90 @@ -0,0 +1,89 @@ +! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! +! +! Maintainers : support@fluidnumerics.com +! 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