-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added general unit test functionality from FLEXI. First unit test is …
…employed for readintools define parameters functions.
- Loading branch information
1 parent
8e7e879
commit 470b4de
Showing
5 changed files
with
338 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -77,3 +77,6 @@ CMakeFiles/ | |
|
||
# doxygen build folder | ||
doxygen/ | ||
|
||
# unit test | ||
unitTests/bin/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#================================================================================================================================= | ||
# Copyright (c) 2010-2021 Prof. Claus-Dieter Munz | ||
# This file is part of FLEXI, a high-order accurate framework for numerically solving PDEs with discontinuous Galerkin methods. | ||
# For more information see https://www.flexi-project.org and https://nrg.iag.uni-stuttgart.de/ | ||
# | ||
# FLEXI is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
# | ||
# FLEXI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License v3.0 for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with FLEXI. If not, see <http://www.gnu.org/licenses/>. | ||
#================================================================================================================================= | ||
|
||
#add_unit_test(<target> <sources>...) | ||
# | ||
# Adds test executable, <target>, built from <sources> and | ||
# adds the test so that CTest will run it. | ||
# Both the executable and the test will be named <target>. | ||
# | ||
function(add_unit_test target) | ||
# Add executable and libraries | ||
ADD_EXECUTABLE(${target} ${ARGN}) | ||
TARGET_LINK_LIBRARIES(${target} libpiclasshared) | ||
# Set properties of target | ||
SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_FLAGS ${PICLAS_COMPILE_FLAGS}) | ||
SET_TARGET_PROPERTIES(${target} PROPERTIES LINKER_LANGUAGE Fortran) | ||
SET_TARGET_PROPERTIES(${target} | ||
PROPERTIES | ||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/unitTests/lib" | ||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/unitTests/lib" | ||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/unitTests/bin") | ||
# Add this test to the global list of tests | ||
SET(UNIT_TEST_TARGETS ${UNIT_TEST_TARGETS} ${target} PARENT_SCOPE) | ||
# Add the test | ||
ADD_TEST(NAME ${target} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/unitTests | ||
COMMAND ${CMAKE_BINARY_DIR}/unitTests/bin/${target}) | ||
endfunction() | ||
|
||
# Enable testing in general | ||
ENABLE_TESTING() | ||
|
||
# Add the unit tests | ||
add_unit_test(ReadInTools ./unitTests/ReadInTools.f90) | ||
#add_unit_test(NodesAndWeights ./unitTests/NodesAndWeights.f90) | ||
#add_unit_test(Vandermonde ./unitTests/Vandermonde.f90) | ||
#add_unit_test(DerivativeMatrix ./unitTests/DerivativeMatrix.f90) | ||
#add_unit_test(ChangeBasis ./unitTests/ChangeBasis.f90) | ||
#add_unit_test(SurfInt ./unitTests/SurfInt.f90) | ||
#add_unit_test(ProlongToFace ./unitTests/ProlongToFace.f90) | ||
|
||
# Perform unit tests when the last test has been compiled | ||
ADD_CUSTOM_TARGET( all_tests ALL | ||
DEPENDS ${UNIT_TEST_TARGETS}) | ||
ADD_CUSTOM_COMMAND(TARGET all_tests | ||
COMMENT "Run unit tests" | ||
POST_BUILD COMMAND ctest --output-on-failure | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) |
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,207 @@ | ||
!================================================================================================================================= | ||
! Copyright (c) 2010-2021 Prof. Claus-Dieter Munz | ||
! This file is part of FLEXI, a high-order accurate framework for numerically solving PDEs with discontinuous Galerkin methods. | ||
! For more information see https://www.flexi-project.org and https://nrg.iag.uni-stuttgart.de/ | ||
! | ||
! FLEXI is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License | ||
! as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
! | ||
! FLEXI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License v3.0 for more details. | ||
! | ||
! You should have received a copy of the GNU General Public License along with FLEXI. If not, see <http://www.gnu.org/licenses/>. | ||
!================================================================================================================================= | ||
#include "piclas.h" | ||
|
||
!================================================================================================================================== | ||
!> Unit test 'ReadInToolsUnitTest' | ||
!> Test the module: MOD_ReadInTools | ||
!================================================================================================================================== | ||
PROGRAM ReadInToolsUnitTest | ||
! MODULES | ||
USE MOD_Globals | ||
USE MOD_ReadInTools | ||
USE MOD_MPI, ONLY: InitMPI | ||
IMPLICIT NONE | ||
!---------------------------------------------------------------------------------------------------------------------------------- | ||
! LOCAL VARIABLES | ||
INTEGER :: nArgs,i | ||
CHARACTER(LEN=255),PARAMETER :: FileName='ReadInTools.ini' | ||
INTEGER :: intOpt | ||
INTEGER :: intOpt_def | ||
INTEGER :: intOpt_mult | ||
INTEGER :: intOpt_mult_A | ||
REAL :: realOpt | ||
REAL :: realOptsci | ||
REAL :: realOpt_def | ||
REAL :: realOpt_defsci | ||
REAL :: realOpt_mult | ||
REAL :: realOpt_mult_A | ||
REAL :: realOpt_multsci | ||
REAL :: realOpt_multsci_A | ||
LOGICAL :: logOpt | ||
LOGICAL :: logOpt_def | ||
LOGICAL :: logOpt_mult | ||
LOGICAL :: logOpt_mult_A | ||
character(len=255) :: strOpt | ||
character(len=255) :: strOpt_def | ||
character(len=255) :: strOpt_mult | ||
character(len=255) :: strOpt_mult_A | ||
|
||
INTEGER :: intArrayOpt(3) | ||
INTEGER :: intArrayOpt_def(3) | ||
INTEGER :: intArrayOpt_mult(2) | ||
INTEGER :: intArrayOpt_mult_A(2) | ||
REAL :: realArrayOpt(3) | ||
REAL :: realArrayOptsci(2) | ||
REAL :: realArrayOpt_def(3) | ||
REAL :: realArrayOpt_defsci(2) | ||
REAL :: realArrayOpt_mult(2) | ||
REAL :: realArrayOpt_mult_A(2) | ||
REAL :: realArrayOpt_multsci(2) | ||
REAL :: realArrayOpt_multsci_A(2) | ||
LOGICAL :: logArrayOpt(2) | ||
LOGICAL :: logArrayOpt_def(2) | ||
LOGICAL :: logArrayOpt_mult(2) | ||
LOGICAL :: logArrayOpt_mult_A(2) | ||
!character(len=255) :: strArrayOpt(2) | ||
!character(len=255) :: strArrayOpt_def(2) | ||
!character(len=255) :: strArrayOpt_mult(2) | ||
!character(len=255) :: strArrayOpt_mult_A(2) | ||
!================================================================================================================================== | ||
CALL InitMPI() | ||
! Check for command line arguments to generate the reference solution | ||
nArgs=COMMAND_ARGUMENT_COUNT() | ||
IF (nArgs.GT.0) THEN | ||
WRITE(*,*) 'ERROR - Unknown command line argument.' | ||
STOP -1 | ||
END IF | ||
|
||
CALL prms%SetSection("UnitTest") | ||
CALL prms%CreateIntOption('intOpt' , "Description IntOpt") | ||
CALL prms%CreateIntOption('intOpt_def' , "Description IntOpt with default value", '-1') | ||
CALL prms%CreateIntOption('intOpt_mult' , "Description IntOpt multiple", multiple=.TRUE.) | ||
CALL prms%CreateRealOption('realOpt' , "Description RealOpt") | ||
CALL prms%CreateRealOption('realOptsci' , "Description RealOpt") | ||
CALL prms%CreateRealOption('realOpt_def' , "Description RealOpt with default value", '-1.00') | ||
CALL prms%CreateRealOption('realOpt_defsci' , "Description RealOpt with default value scientific", '0.3e-7') | ||
CALL prms%CreateRealOption('realOpt_mult' , "Description RealOpt multiple", multiple=.TRUE.) | ||
CALL prms%CreateRealOption('realOpt_multsci' , "Description RealOpt multiple", multiple=.TRUE.) | ||
CALL prms%CreateLogicalOption('logOpt' , "Description LogOpt") | ||
CALL prms%CreateLogicalOption('logOpt_def' , "Description LogOpt with default value", 'T') | ||
CALL prms%CreateLogicalOption('logOpt_mult' , "Description LogOpt multiple", multiple=.TRUE.) | ||
CALL prms%CreateStringOption('strOpt' , "Description StrOpt") | ||
CALL prms%CreateStringOption('strOpt_def' , "Description StrOpt with default value", 'dummyValue') | ||
CALL prms%CreateStringOption('strOpt_mult' , "Description StrOpt multiple", multiple=.TRUE.) | ||
|
||
CALL prms%CreateIntArrayOption('intArrayOpt' , "Description IntOpt", no=0) | ||
CALL prms%CreateIntArrayOption('intArrayOpt_def' , "Description IntOpt with default value", '-1,0,-3', no=2) | ||
CALL prms%CreateIntArrayOption('intArrayOpt_mult' , "Description IntOpt multiple", multiple=.TRUE., no=0) | ||
CALL prms%CreateRealArrayOption('realArrayOpt' , "Description RealOpt", no=0) | ||
CALL prms%CreateRealArrayOption('realArrayOptsci' , "Description RealOpt", no=0) | ||
CALL prms%CreateRealArrayOption('realArrayOpt_def' , "Description RealOpt with default value" , '-1.00,5.,22', no=3) | ||
CALL prms%CreateRealArrayOption('realArrayOpt_defsci' , "Description RealOpt with default value scientific" , '0.3e-7,-5e2', no=2) | ||
CALL prms%CreateRealArrayOption('realArrayOpt_mult' , "Description RealOpt multiple" , multiple=.TRUE., no=0) | ||
CALL prms%CreateRealArrayOption('realArrayOpt_multsci' , "Description RealOpt multiple" , multiple=.TRUE., no=0) | ||
CALL prms%CreateLogicalArrayOption('logArrayOpt' , "Description LogOpt", no=0) | ||
CALL prms%CreateLogicalArrayOption('logArrayOpt_def' , "Description LogOpt with default value", '(/T,F/)', no=2) | ||
CALL prms%CreateLogicalArrayOption('logArrayOpt_mult' , "Description LogOpt multiple", multiple=.TRUE., no=0) | ||
!CALL prms%CreateStringArrayOption('strArrayOpt' , "Description StrOpt") | ||
!CALL prms%CreateStringArrayOption('strArrayOpt_def' , "Description StrOpt with default value", 'dum1,dum2') | ||
!CALL prms%CreateStringArrayOption('strArrayOpt_mult' , "Description StrOpt multiple", multiple=.TRUE.) | ||
|
||
!CALL PrintDefaultParameterFile(.FALSE.) | ||
CALL prms%read_options(FileName) | ||
|
||
intOpt = GETINT('intOpt' ) | ||
intOpt_def = GETINT('intOpt_def' ) | ||
IF (intOpt.NE.intOpt_def) CALL Abort(__STAMP__,"intOpt failed") | ||
intOpt_mult = GETINT('intOpt_mult' ) | ||
intOpt_mult_A = GETINT('intOpt_mult' ) | ||
IF (intOpt_mult.NE.intOpt_mult_A) CALL Abort(__STAMP__,"intOpt_mult failed") | ||
realOpt = GETREAL('realOpt' ) | ||
realOpt_def = GETREAL('realOpt_def' ) | ||
IF (realOpt.NE.realOpt_def) CALL Abort(__STAMP__,"realOpt failed") | ||
realOptsci = GETREAL('realOptsci' ) | ||
realOpt_defsci = GETREAL('realOpt_defsci' ) | ||
IF (realOptsci.NE.realOpt_defsci) CALL Abort(__STAMP__,"realOptsci failed") | ||
realOpt_mult = GETREAL('realOpt_mult' ) | ||
realOpt_mult_A = GETREAL('realOpt_mult' ) | ||
IF (realOpt_mult.NE.realOpt_mult_A) CALL Abort(__STAMP__,"realOpt_mult failed") | ||
realOpt_multsci = GETREAL('realOpt_multsci' ) | ||
realOpt_multsci_A = GETREAL('realOpt_multsci' ) | ||
IF (realOpt_multsci.NE.realOpt_multsci_A) CALL Abort(__STAMP__,"realOpt_multsci failed") | ||
logOpt = GETLOGICAL('logOpt' ) | ||
logOpt_def = GETLOGICAL('logOpt_def' ) | ||
IF (logOpt.NEQV.logOpt_def) CALL Abort(__STAMP__,"logOpt failed") | ||
logOpt_mult = GETLOGICAL('logOpt_mult' ) | ||
logOpt_mult_A = GETLOGICAL('logOpt_mult' ) | ||
IF (logOpt_mult.NEQV.logOpt_mult_A) CALL Abort(__STAMP__,"logOpt_mult failed") | ||
strOpt = GETSTR('strOpt' ) | ||
strOpt_def = GETSTR('strOpt_def' ) | ||
IF (strOpt.NE.strOpt_def) CALL Abort(__STAMP__,"strOpt failed") | ||
strOpt_mult = GETSTR('strOpt_mult' ) | ||
strOpt_mult_A = GETSTR('strOpt_mult' ) | ||
IF (strOpt_mult.NE.strOpt_mult_A) CALL Abort(__STAMP__,"strOpt_mult failed") | ||
|
||
intArrayOpt = GETINTARRAY('intArrayOpt',3 ) | ||
intArrayOpt_def = GETINTARRAY('intArrayOpt_def',3) | ||
DO i=1,3 | ||
IF (intArrayOpt(i).NE.intArrayOpt_def(i)) CALL Abort(__STAMP__,"intArrayOpt failed") | ||
END DO | ||
intArrayOpt_mult = GETINTARRAY('intArrayOpt_mult', 2) | ||
intArrayOpt_mult_A = GETINTARRAY('intArrayOpt_mult', 2) | ||
DO i=1,2 | ||
IF (intArrayOpt_mult(i).NE.intArrayOpt_mult_A(i)) CALL Abort(__STAMP__,"intArrayOpt_mult failed") | ||
END DO | ||
realArrayOpt = GETREALARRAY('realArrayOpt', 3) | ||
realArrayOpt_def = GETREALARRAY('realArrayOpt_def', 3) | ||
DO i=1,3 | ||
IF (realArrayOpt(i).NE.realArrayOpt_def(i)) CALL Abort(__STAMP__,"realArrayOpt failed") | ||
END DO | ||
realArrayOptsci = GETREALARRAY('realArrayOptsci', 2) | ||
realArrayOpt_defsci = GETREALARRAY('realArrayOpt_defsci', 2) | ||
DO i=1,2 | ||
IF (realArrayOptsci(i).NE.realArrayOpt_defsci(i)) CALL Abort(__STAMP__,"realArrayOptsci failed") | ||
END DO | ||
realArrayOpt_mult = GETREALARRAY('realArrayOpt_mult', 2) | ||
realArrayOpt_mult_A = GETREALARRAY('realArrayOpt_mult', 2) | ||
DO i=1,2 | ||
IF (realArrayOpt_mult(i).NE.realArrayOpt_mult_A(i)) CALL Abort(__STAMP__,"realArrayOpt_mult failed") | ||
END DO | ||
realArrayOpt_multsci = GETREALARRAY('realArrayOpt_multsci', 2) | ||
realArrayOpt_multsci_A = GETREALARRAY('realArrayOpt_multsci', 2) | ||
DO i=1,2 | ||
IF (realArrayOpt_multsci(i).NE.realArrayOpt_multsci_A(i)) CALL Abort(__STAMP__,"realArrayOpt_multsci failed") | ||
END DO | ||
logArrayOpt = GETLOGICALARRAY('logArrayOpt', 2) | ||
logArrayOpt_def = GETLOGICALARRAY('logArrayOpt_def', 2) | ||
DO i=1,2 | ||
IF (logArrayOpt(i).NEQV.logArrayOpt_def(i)) CALL Abort(__STAMP__,"logArrayOpt failed") | ||
END DO | ||
logArrayOpt_mult = GETLOGICALARRAY('logArrayOpt_mult', 2) | ||
logArrayOpt_mult_A = GETLOGICALARRAY('logArrayOpt_mult', 2) | ||
DO i=1,2 | ||
IF (logArrayOpt_mult(i).NEQV.logArrayOpt_mult_A(i)) CALL Abort(__STAMP__,"logArrayOpt_mult failed") | ||
END DO | ||
!strArrayOpt = GETSTRARRAY('strArrayOpt', 2) | ||
!strArrayOpt_def = GETSTRARRAY('strArrayOpt_def', 2) | ||
!DO i=1,2 | ||
!IF (strArrayOpt(i).NE.strArrayOpt_def(i)) CALL Abort(__STAMP__,"strArrayOpt failed") | ||
!END DO | ||
!strArrayOpt_mult = GETSTRARRAY('strArrayOpt_mult', 2) | ||
!strArrayOpt_mult_A = GETSTRARRAY('strArrayOpt_mult', 2) | ||
!DO i=1,2 | ||
!IF (strArrayOpt_mult(i).NE.strArrayOpt_mult_A(i)) CALL Abort(__STAMP__,"strArrayOpt_mult failed") | ||
!END DO | ||
|
||
#if USE_MPI | ||
! free the communicator | ||
!CALL MPI_BARRIER (MPI_COMM_WORLD,IERROR) | ||
!CALL MPI_COMM_FREE(MPI_COMM_WORLD,IERROR) | ||
! we also have to finalize MPI itself here | ||
CALL MPI_FINALIZE(iError) | ||
IF(iError .NE. 0) STOP 'MPI finalize error' | ||
#endif | ||
|
||
END PROGRAM ReadInToolsUnitTest |
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,55 @@ | ||
!================================================================================================================================= | ||
! Copyright (c) 2010-2021 Prof. Claus-Dieter Munz | ||
! This file is part of FLEXI, a high-order accurate framework for numerically solving PDEs with discontinuous Galerkin methods. | ||
! For more information see https://www.flexi-project.org and https://nrg.iag.uni-stuttgart.de/ | ||
! | ||
! FLEXI is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License | ||
! as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
! | ||
! FLEXI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License v3.0 for more details. | ||
! | ||
! You should have received a copy of the GNU General Public License along with FLEXI. If not, see <http://www.gnu.org/licenses/>. | ||
!================================================================================================================================= | ||
|
||
!=============================================================================== | ||
! Default Parameter File generated using 'piclas --help' | ||
! compiled at : Aug 10 2016 10:45:59 | ||
!=============================================================================== | ||
!================================================================================================== | ||
! UnitTest | ||
!================================================================================================== | ||
intOpt = -1 | ||
intOpt_mult = -4 | ||
intOpt_mult = -4 | ||
realOpt = -1.00 | ||
realOptsci = 0.3E-07 | ||
realOpt_mult = 3.14 | ||
realOpt_mult = 3.14 | ||
realOpt_multsci = -0.25E-07 | ||
realOpt_multsci = -0.25E-07 | ||
logOpt = T | ||
logOpt_mult = F | ||
logOpt_mult = F | ||
strOpt = dummyValue | ||
strOpt_mult = dummyValue | ||
strOpt_mult = dummyValue | ||
|
||
|
||
intArrayOpt = (/ -1, 0, -3 /) | ||
intArrayOpt_mult = (/ 100, 22 /) | ||
intArrayOpt_mult = (/ 100, 22 /) | ||
realArrayOpt = (/ -1.00, 5.0, 22.0 /) | ||
realArrayOptsci = (/ 0.3E-07, -0.5E+03 /) | ||
realArrayOpt_mult = (/ 0.5, -2.1 /) | ||
realArrayOpt_mult = (/ 0.5, -2.1 /) | ||
realArrayOpt_multsci = (/ -0.25E-07, 3.3 /) | ||
realArrayOpt_multsci = (/ -0.25E-07, 3.3 /) | ||
|
||
logArrayOpt = (/ T, F /) | ||
logArrayOpt_mult = (/ F, T /) | ||
logArrayOpt_mult = (/ F, T /) | ||
strArrayOpt = (/ dum1, dum2 /) | ||
strArrayOpt_mult = (/ dum1, dum2 /) | ||
strArrayOpt_mult = (/ dum1, dum2 /) | ||
|