diff --git a/.cproject b/.cproject index af5b4a0bbd99bf8fa5795fac0ee2cdd899225c0c..89a0873e084f7a0d00b9950c1919d6259972f95c 100644 --- a/.cproject +++ b/.cproject @@ -5,26 +5,37 @@ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.2134791445" moduleId="org.eclipse.cdt.core.settings" name="Default"> <externalSettings/> <extensions> - <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> </extensions> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration buildProperties="" id="cdt.managedbuild.toolchain.gnu.base.2134791445" name="Default" parent="org.eclipse.cdt.build.core.emptycfg"> + <configuration buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.base.2134791445" name="Default" parent="org.eclipse.cdt.build.core.emptycfg"> <folderInfo id="cdt.managedbuild.toolchain.gnu.base.2134791445.1799170915" name="/" resourcePath=""> <toolChain id="cdt.managedbuild.toolchain.gnu.base.1762402759" name="cdt.managedbuild.toolchain.gnu.base" superClass="cdt.managedbuild.toolchain.gnu.base"> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.840154721" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/> - <builder id="cdt.managedbuild.target.gnu.builder.base.573876641" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="cdt.managedbuild.target.gnu.builder.base"/> + <builder id="cdt.managedbuild.target.gnu.builder.base.573876641" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/> <tool id="cdt.managedbuild.tool.gnu.archiver.base.958650307" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> - <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1237330740" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"/> - <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.315517693" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1237330740" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1856262209" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.315517693" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.950045328" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> <tool id="cdt.managedbuild.tool.gnu.c.linker.base.1786292703" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/> - <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1133414639" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/> - <tool id="cdt.managedbuild.tool.gnu.assembler.base.336757143" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1133414639" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.692614544" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool id="cdt.managedbuild.tool.gnu.assembler.base.336757143" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1329383797" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> </toolChain> </folderInfo> </configuration> diff --git a/CMakeLists.txt b/CMakeLists.txt index 34c9cfe7e171df78356b26eb41f2eba1141d6041..7e2fb26ed125685f7e68d9556774e695e5fe0813 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,11 +105,11 @@ endif() #### # Check for MPI # -find_package( MPI ) -if( MPI_CXX_FOUND ) - set( BUILD_MPI TRUE ) - message( "MPI headers found -- ${MPI_CXX_INCLUDE_PATH}") -endif() +#find_package( MPI ) +#if( MPI_CXX_FOUND ) +# set( BUILD_MPI TRUE ) +# message( "MPI headers found -- ${MPI_CXX_INCLUDE_PATH}") +#endif() #### # Check for some system header @@ -227,6 +227,7 @@ INSTALL( FILES ${PROJECT_BUILD_PATH}/tnlConfig.h DESTINATION include/tnl-${tnlVe #Nastavime cesty k hlavickovym souborum a knihovnam INCLUDE_DIRECTORIES( src ) +INCLUDE_DIRECTORIES( tests ) INCLUDE_DIRECTORIES( ${PROJECT_BUILD_PATH} ) LINK_DIRECTORIES( ${LIBRARY_OUTPUT_PATH} ) diff --git a/examples/heat-equation/CMakeLists.txt b/examples/heat-equation/CMakeLists.txt index 04647467526a318b035d8dc5fe32c96e62223cb0..c927fece5cc07d99727e771ed261be3811ae36f9 100755 --- a/examples/heat-equation/CMakeLists.txt +++ b/examples/heat-equation/CMakeLists.txt @@ -1,38 +1,28 @@ set( tnl_heat_equation_SOURCES - tnlZeroRightHandSide_impl.h - tnlZeroRightHandSide.h - tnlTimeFunction_impl.h - tnlTimeFunction.h + tnlHeatEquationEocRhs.h tnlRightHandSide_impl.h tnlRightHandSide.h - tnlNeumannBoundaryConditions_impl.h - tnlNeumannBoundaryConditions.h - tnlDirichletBoundaryConditions_impl.h - tnlDirichletBoundaryConditions.h tnlAnalyticSolution_impl.h tnlAnalyticSolution.h - main.cpp + tnl-heat-equation.cpp + tnl-heat-equation-eoc.cpp heatEquationSolver_impl.h heatEquationSolver.h heatEquationSetter_impl.h - heatEquationSetter.h - heatEquationConfig.h ) + heatEquationSetter.h + heatEquationEocRhs.h ) -ADD_EXECUTABLE(tnl-heat-equation${debugExt} ${tnl_heat_equation_SOURCES}) -target_link_libraries (tnl-heat-equation${debugExt} tnl${debugExt}-${tnlVersion} ) +#ADD_EXECUTABLE(tnl-heat-equation${debugExt} tnl-heat-equation.cpp) +#target_link_libraries (tnl-heat-equation${debugExt} tnl${debugExt}-${tnlVersion} ) -INSTALL( TARGETS tnl-heat-equation${debugExt} +ADD_EXECUTABLE(tnl-heat-equation-eoc-test${debugExt} tnl-heat-equation-eoc.cpp) +target_link_libraries (tnl-heat-equation-eoc-test${debugExt} tnl${debugExt}-${tnlVersion} ) + +INSTALL( TARGETS #tnl-heat-equation${debugExt} + tnl-heat-equation-eoc-test${debugExt} RUNTIME DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) -INSTALL( FILES #Makefile - run-init-mesh - run-heat-equation-testy-laplace-konvergence - run-heat-equation-testy-konvergence - run-heat-equation - heat-equation.cfg.desc - debugging_parameters - EOCtest - EOCtest-adaptivity-cycle - +INSTALL( FILES tnl-run-heat-equation-eoc-test + tnl-run-heat-equation DESTINATION share/tnl-${tnlVersion}/examples/heat-equation ) diff --git a/examples/heat-equation/EOCtest b/examples/heat-equation/EOCtest deleted file mode 100755 index 4c9da0b64802e1192a6993a8355d036e4769520c..0000000000000000000000000000000000000000 --- a/examples/heat-equation/EOCtest +++ /dev/null @@ -1,185 +0,0 @@ -#!/bin/bash - -LD_LIBRARY_PATH=/home/szekely/local/lib -export LD_LIBRARY_PATH - -dimension=2 -proportions=1 -initDofSize=8 -analyticFunction="sin-wave" -timeFunction="cosinus" -snapshotPeriod=0.05 -finalTime=1 -mersonAdaptivity=1.0e-5 -numberOfIterations=8 -#{8..1024dofs} -scale=2 -origin=0 - -amplitude=1.0 -waveLength=1.0 -waveLengthX=1.0 -waveLengthY=1.0 -waveLengthZ=1.0 -wavesNumber=0.0 -wavesNumberX=0.0 -wavesNumberY=0.0 -wavesNumberZ=0.0 -phase=0.0 -phaseX=0.0 -phaseY=0.0 -phaseZ=0.0 -sigma=1.0 - -dofs=${initDofSize} - -for ((i=1;i<=${numberOfIterations};i++)) -do - -tnl-grid-setup --dimensions ${dimension} \ - --proportions-x ${proportions} \ - --proportions-y ${proportions} \ - --proportions-z ${proportions} \ - --origin-x ${origin} \ - --origin-y ${origin} \ - --origin-z ${origin} \ - --size-x ${dofs} \ - --size-y ${dofs} \ - --size-z ${dofs} \ - -tnl-discrete --mesh mesh.tnl \ - --function ${analyticFunction} \ - --output-file u-ini.tnl \ - --amplitude ${amplitude} \ - --wave-length ${waveLength} \ - --wave-length-x ${waveLengthX} \ - --wave-length-y ${waveLengthY} \ - --wave-length-z ${waveLengthZ} \ - --waves-number ${wavesNumber} \ - --waves-number-x ${wavesNumberX} \ - --waves-number-y ${wavesNumberY} \ - --waves-number-z ${wavesNumberZ} \ - --phase ${phase} \ - --phase-x ${phaseX} \ - --phase-y ${phaseY} \ - --phase-z ${phaseZ} \ - --sigma ${sigma} \ - -./heat-equation_AV --dimensions ${dimension} \ - --time-discretisation explicit \ - --discrete-solver merson \ - --merson-adaptivity ${mersonAdaptivity}\ - --time-function ${timeFunction}\ - --analytic-space-function ${analyticFunction}\ - --amplitude ${amplitude} \ - --wave-length ${waveLength} \ - --wave-length-x ${waveLengthX} \ - --wave-length-y ${waveLengthY} \ - --wave-length-z ${waveLengthZ} \ - --waves-number ${wavesNumber} \ - --waves-number-x ${wavesNumberX} \ - --waves-number-y ${wavesNumberY} \ - --waves-number-z ${wavesNumberZ} \ - --phase ${phase} \ - --phase-x ${phaseX} \ - --phase-y ${phaseY} \ - --phase-z ${phaseZ} \ - --sigma ${sigma} \ - --sigma ${sigma} \ - --snapshot-period ${snapshotPeriod} \ - --final-time ${finalTime} \ - --solution-convergence-test 1 \ - -rm u-ini.tnl - -tnl-diff --mesh mesh.tnl \ - --input-files numericalSolution-*.tnl analyticSolution-*.tnl \ - --mode halves \ - --output-file ${dofs} \ - -rm *.tnl - -dofs=$((${scale} * $dofs)) - -done - -file="EOC-${analyticFunction}-${timeFunction}-${dimension}D-${finalTime}T-adaptivity${mersonAdaptivity}" - -rm ${file} -echo -e "#\tL1 diff.\t\tEOC\t\tL2 diff.\t\tEOC\t\tLmax diff.\t\tEOC" >> ${file} - -echo -e -n "${initDofSize}\t" >> ${file} -nactenyRadek=$( tail -1 ${initDofSize}) -for zaznam in ${nactenyRadek} -do - -hodnota=$(echo $zaznam | sed 's/e/\*10\^/' | bc -l) -if [[ ${hodnota} =~ ^\. ]]; then -echo -e -n "0${hodnota}\t\t \t\t" >> ${file} -else -echo -e -n "${hodnota}\t\t \t\t" >> ${file} -fi - -done -echo -e -n "\n" >> ${file} - - -${radek} >> ${file} - -soubor1=$((${initDofSize}/${scale})) -soubor2=${initDofSize} - -for ((i=1;i<${numberOfIterations};i++)) -do - -soubor1=$((2 * $soubor1)) -soubor2=$((2 * $soubor2)) - -IFS=' ' read -a posledniRadek1 <<< $(tail -1 $soubor1) -IFS=' ' read -a posledniRadek2 <<< $(tail -1 $soubor2) -#{pres specialni promenou IFS utvorime pole z retezce} - -echo -e -n "${soubor2}\t" >> ${file} - -for j in {0..2} -do - -echo -e -n "${posledniRadek2[j]}\t\t" >> ${file} - -prevedenyVyraz=$(echo "l((${posledniRadek2[$j]})/(${posledniRadek1[$j]}))/l(0.5)" | sed 's/e/\*10\^/g') -hodnota=$(echo "${prevedenyVyraz}" | bc -l) -hodnota=$(echo "scale=3; ${hodnota}/1" | bc) -#hodnota =$(echo "${prevedenyVyraz}" | bc -l) -#{g v retezci aby nahradilo vsechny vyskyty v souboru} -if [[ ${hodnota} =~ ^\. ]]; then -echo -e -n "0${hodnota}\t\t" >> ${file} -else -if [[ ${hodnota} =~ ^\-\. ]]; then -pom=$(echo "${hodnota}" | sed 's/-\./-0\./') -echo -e -n "${pom}\t\t" >> ${file} -else -echo -e -n "${hodnota}\t\t" >> ${file} -fi -fi - -done - -echo -e -n "\n" >> ${file} - -done - -echo -e -n "\n\n\n" >> ${file} - -echo -e "PARAMETERS:\n" >> ${file} -echo -e " dimensions = ${dimension}\n proportions = ${proportions}\n analytic function = ${analyticFunction}\n time function = ${timeFunction}\n snapshot period = ${snapshotPeriod}\n final time = ${finalTime}\n adaptivity = ${mersonAdaptivity}\n origin = ${origin}\n\n" >> ${file} -echo -e " amplitude = ${amplitude}\n wave length = ${waveLength}\n wave length x = ${waveLengthX}\n wave length y = ${waveLengthY}\n wave length z = ${waveLengthZ=1.0}\n wave number = ${wavesNumber}\n waves number x = ${wavesNumberX}\n waves number y = ${wavesNumberY}\n waves number z = ${wavesNumberZ}\n phase = ${phase}\n phase x = ${phaseX}\n phase y = ${phaseY}\n phase z = ${phaseZ}\n sigma = ${sigma}" >> ${file} - - -soubor=$((${initDofSize}/${scale})) -for ((i=1;i<=${numberOfIterations};i++)) -do - -soubor=$((${soubor}*${scale})) -rm ${soubor} - -done diff --git a/examples/heat-equation/EOCtest-adaptivity-cycle b/examples/heat-equation/EOCtest-adaptivity-cycle deleted file mode 100755 index faa40c78f7cc0152b563caeff57c87bdd422157a..0000000000000000000000000000000000000000 --- a/examples/heat-equation/EOCtest-adaptivity-cycle +++ /dev/null @@ -1,194 +0,0 @@ -#!/bin/bash - -LD_LIBRARY_PATH=/home/szekely/local/lib -export LD_LIBRARY_PATH - -dimension=2 -proportions=1 -initDofSize=8 -analyticFunction="exp-bump" -timeFunction="cosinus" -snapshotPeriod=0.01 -finalTime=0.1 -initMersonAdaptivity=1.0e-7 -numberOfAdaptivityIter=2 -adaptivityDiff=100 -numberOfIterations=8 -#{8..1024dofs} -scale=2 -origin=0 - -amplitude=1.0 -waveLength=1.0 -waveLengthX=1.0 -waveLengthY=1.0 -waveLengthZ=1.0 -wavesNumber=0.0 -wavesNumberX=0.0 -wavesNumberY=0.0 -wavesNumberZ=0.0 -phase=0.0 -phaseX=0.0 -phaseY=0.0 -phaseZ=0.0 -sigma=1.0 - -dofs=${initDofSize} -mersonAdaptivity=${initMersonAdaptivity} - -for ((k=1;k<=${numberOfAdaptivityIter};k++)) -do -for ((i=1;i<=${numberOfIterations};i++)) -do - -tnl-grid-setup --dimensions ${dimension} \ - --proportions-x ${proportions} \ - --proportions-y ${proportions} \ - --proportions-z ${proportions} \ - --origin-x ${origin} \ - --origin-y ${origin} \ - --origin-z ${origin} \ - --size-x ${dofs} \ - --size-y ${dofs} \ - --size-z ${dofs} \ - -tnl-discrete --mesh mesh.tnl \ - --function ${analyticFunction} \ - --output-file u-ini.tnl \ - --amplitude ${amplitude} \ - --wave-length ${waveLength} \ - --wave-length-x ${waveLengthX} \ - --wave-length-y ${waveLengthY} \ - --wave-length-z ${waveLengthZ} \ - --waves-number ${wavesNumber} \ - --waves-number-x ${wavesNumberX} \ - --waves-number-y ${wavesNumberY} \ - --waves-number-z ${wavesNumberZ} \ - --phase ${phase} \ - --phase-x ${phaseX} \ - --phase-y ${phaseY} \ - --phase-z ${phaseZ} \ - --sigma ${sigma} \ - -./heat-equation_AV --dimensions ${dimension} \ - --time-discretisation explicit \ - --discrete-solver merson \ - --merson-adaptivity ${mersonAdaptivity}\ - --time-function ${timeFunction}\ - --analytic-space-function ${analyticFunction}\ - --amplitude ${amplitude} \ - --wave-length ${waveLength} \ - --wave-length-x ${waveLengthX} \ - --wave-length-y ${waveLengthY} \ - --wave-length-z ${waveLengthZ} \ - --waves-number ${wavesNumber} \ - --waves-number-x ${wavesNumberX} \ - --waves-number-y ${wavesNumberY} \ - --waves-number-z ${wavesNumberZ} \ - --phase ${phase} \ - --phase-x ${phaseX} \ - --phase-y ${phaseY} \ - --phase-z ${phaseZ} \ - --sigma ${sigma} \ - --sigma ${sigma} \ - --snapshot-period ${snapshotPeriod} \ - --final-time ${finalTime} \ - --solution-convergence-test 1 \ - -rm u-ini.tnl - -tnl-diff --mesh mesh.tnl \ - --input-files numericalSolution-*.tnl analyticSolution-*.tnl \ - --mode halves \ - --output-file ${dofs} \ - -rm *.tnl - -dofs=$((${scale} * $dofs)) - -done - -file="EOC-${analyticFunction}-${timeFunction}-${dimension}D-${finalTime}T-adaptivity${mersonAdaptivity}" - -rm ${file} -echo -e "#\tL1 diff.\t\tEOC\t\tL2 diff.\t\tEOC\t\tLmax diff.\t\tEOC" >> ${file} - -echo -e -n "${initDofSize}\t" >> ${file} -nactenyRadek=$( tail -1 ${initDofSize}) -for zaznam in ${nactenyRadek} -do - -hodnota=$(echo $zaznam | sed 's/e/\*10\^/' | bc -l) -if [[ ${hodnota} =~ ^\. ]]; then -echo -e -n "0${hodnota}\t\t \t\t" >> ${file} -else -echo -e -n "${hodnota}\t\t \t\t" >> ${file} -fi - -done -echo -e -n "\n" >> ${file} - - -${radek} >> ${file} - -soubor1=$((${initDofSize}/${scale})) -soubor2=${initDofSize} - -for ((i=1;i<${numberOfIterations};i++)) -do - -soubor1=$((2 * $soubor1)) -soubor2=$((2 * $soubor2)) - -IFS=' ' read -a posledniRadek1 <<< $(tail -1 $soubor1) -IFS=' ' read -a posledniRadek2 <<< $(tail -1 $soubor2) -#{pres specialni promenou IFS utvorime pole z retezce} - -echo -e -n "${soubor2}\t" >> ${file} - -for j in {0..2} -do - -echo -e -n "${posledniRadek2[j]}\t\t" >> ${file} - -prevedenyVyraz=$(echo "l((${posledniRadek2[$j]})/(${posledniRadek1[$j]}))/l(0.5)" | sed 's/e/\*10\^/g') -hodnota=$(echo "${prevedenyVyraz}" | bc -l) -hodnota=$(echo "scale=3; ${hodnota}/1" | bc) -#hodnota =$(echo "${prevedenyVyraz}" | bc -l) -#{g v retezci aby nahradilo vsechny vyskyty v souboru} -if [[ ${hodnota} =~ ^\. ]]; then -echo -e -n "0${hodnota}\t\t" >> ${file} -else -if [[ ${hodnota} =~ ^\-\. ]]; then -pom=$(echo "${hodnota}" | sed 's/-\./-0\./') -echo -e -n "${pom}\t\t" >> ${file} -else -echo -e -n "${hodnota}\t\t" >> ${file} -fi -fi - -done - -echo -e -n "\n" >> ${file} - -done - -echo -e -n "\n\n\n" >> ${file} - -echo -e "PARAMETERS:\n" >> ${file} -echo -e " dimensions = ${dimension}\n proportions = ${proportions}\n analytic function = ${analyticFunction}\n time function = ${timeFunction}\n snapshot period = ${snapshotPeriod}\n final time = ${finalTime}\n adaptivity = ${mersonAdaptivity}\n origin = ${origin}\n\n" >> ${file} -echo -e " amplitude = ${amplitude}\n wave length = ${waveLength}\n wave length x = ${waveLengthX}\n wave length y = ${waveLengthY}\n wave length z = ${waveLengthZ=1.0}\n wave number = ${wavesNumber}\n waves number x = ${wavesNumberX}\n waves number y = ${wavesNumberY}\n waves number z = ${wavesNumberZ}\n phase = ${phase}\n phase x = ${phaseX}\n phase y = ${phaseY}\n phase z = ${phaseZ}\n sigma = ${sigma}" >> ${file} - - -soubor=$((${initDofSize}/${scale})) -for ((i=1;i<=${numberOfIterations};i++)) -do - -soubor=$((${soubor}*${scale})) -rm ${soubor} - -done - -mersonAdaptivity=$(echo "(${mersonAdaptivity})/(${adaptivityDiff})" | sed 's/e/\*10\^/g' | bc -l) - -done diff --git a/examples/heat-equation/TOHLEPUST b/examples/heat-equation/TOHLEPUST deleted file mode 100755 index c3b8478d12115ef4beaa98dca27d5114cec18d65..0000000000000000000000000000000000000000 --- a/examples/heat-equation/TOHLEPUST +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash - -dofSize=64 -dimension=2 -proportions=1 - -analyticFunction="sin-wave" -timeFunction="cosinus" - -amplitude=1.0 -waveLength=1.0 -waveLengthX=1.0 -waveLengthY=1.0 -waveLengthZ=1.0 -wavesNumber=0.0 -wavesNumberX=0.0 -wavesNumberY=0.0 -wavesNumberZ=0.0 -phase=0.0 -phaseX=0.0 -phaseY=0.0 -phaseZ=0.0 -sigma=1.0 - -tnl-grid-setup --dimensions ${dimension} \ - --proportions-x ${proportions} \ - --proportions-y ${proportions} \ - --proportions-z ${proportions} \ - --origin-x 0 \ - --origin-y 0 \ - --origin-z 0 \ - --size-x ${dofSize} \ - --size-y ${dofSize} \ - --size-z ${dofSize} \ - -tnl-discrete --mesh mesh.tnl \ - --function ${analyticFunction} \ - --output-file u-ini.tnl \ - --amplitude ${amplitude} \ - --wave-length ${waveLength} \ - --wave-length-x ${waveLengthX} \ - --wave-length-y ${waveLengthY} \ - --wave-length-z ${waveLengthZ} \ - --waves-number ${wavesNumber} \ - --waves-number-x ${wavesNumberX} \ - --waves-number-y ${wavesNumberY} \ - --waves-number-z ${wavesNumberZ} \ - --phase ${phase} \ - --phase-x ${phaseX} \ - --phase-y ${phaseY} \ - --phase-z ${phaseZ} \ - --sigma ${sigma} \ - -./heat-equation --dimensions ${dimension} \ - --time-discretisation explicit \ - --discrete-solver merson \ - --time-function ${timeFunction}\ - --analytic-space-function ${analyticFunction}\ - --amplitude ${amplitude} \ - --wave-length ${waveLength} \ - --wave-length-x ${waveLengthX} \ - --wave-length-y ${waveLengthY} \ - --wave-length-z ${waveLengthZ} \ - --waves-number ${wavesNumber} \ - --waves-number-x ${wavesNumberX} \ - --waves-number-y ${wavesNumberY} \ - --waves-number-z ${wavesNumberZ} \ - --phase ${phase} \ - --phase-x ${phaseX} \ - --phase-y ${phaseY} \ - --phase-z ${phaseZ} \ - --sigma ${sigma} \ - --snapshot-period 0.05 \ - --final-time 1.0 \ - --solution-convergence-test 1 \ - -rm u-ini.tnl - -tnl-diff --mesh mesh.tnl \ - --input-files numericalSolution-*.tnl analyticSolution-*.tnl \ - --mode halves \ - --output-file ${dofSize} \ - -cp 64 POSLI_MI_TOHLE -rm 64 - -rm *.tnl diff --git a/examples/heat-equation/debugging_parameters b/examples/heat-equation/debugging_parameters deleted file mode 100644 index 59c88ae05e48f0f7a449a3a6c072e3a96b02d330..0000000000000000000000000000000000000000 --- a/examples/heat-equation/debugging_parameters +++ /dev/null @@ -1,7 +0,0 @@ -heat-equation --dimensions 3 --time-discretisation explicit --discrete-solver merson --time-function cosinus --analytic-space-function sin-wave --amplitude 1 --wave-length 1 --wave-length-x 1 --wave-length-y 1 --wave-length-z 1 --waves-number 0 --waves-number-x 0 --waves-number-y 0 --waves-number-z 0 --phase 0 --phase-x 0 --phase-y 0 --phase-z 0 --sigma 1 --snapshot-period 0.05 --final-time 1.0 --solution-convergence-test 1 - -tnl-discrete --mesh mesh.tnl --function sin-wave --output-file u-ini.tnl --amplitude 1 --wave-length 1 --wave-length-x 1 --wave-length-y 1 --wave-length-z 1 --waves-number 0 --waves-number-x 0 --waves-number-y 0 --waves-number-z 0 --phase 0 --phase-x 0 --phase-y 0 --phase-z 0 --sigma 1 - -tnl-grid-setup --dimensions 3 --proportions-x 1 --proportions-y 1 --proportions-z 1 --origin-x 0 --origin-y 0 --origin-z 0 --size-x 2 --size-y 2 --size-z 2 - - diff --git a/examples/heat-equation/heat-equation.cfg.desc b/examples/heat-equation/heat-equation.cfg.desc deleted file mode 100644 index 1b665f0e1eee2f565eece8a26a94cd505e5e5db3..0000000000000000000000000000000000000000 --- a/examples/heat-equation/heat-equation.cfg.desc +++ /dev/null @@ -1,44 +0,0 @@ -group Problem -{ - integer dimensions(!) [Number of dimenions the problem is defined in.]; - string problem-name( "heat-eguation" ) [This defines particular problem.]; - string log-file("heat-equation.log") [File name for the log.]; -},[The problem parameters.]; - -group Discretisation -{ - string mesh( "mesh.tnl" ) [A file containing the numerical mesh.]; - string initial-condition("u-ini.tnl"); - string time-discretisation(!) [Time discretisation for the time dependent problems. Can be explicit, semi-implicit or fully-implicit.]; -},[The numerical scheme set-up.]; - -group Solver -{ - string real-type( "double" ) [Precision of the floating point arithmetics. Can be float, double, long-double.]; - string index-type( "int" ) [Indexing type for arrays, vectors, matrices etc. Can be int or long-int.]; - string device( "host" ) [Device to use for the computations. Can be host or cuda.]; - string discrete-solver(!) [The main solver for the discretised problem.]; - real merson-adaptivity(1.0e-4) [Parameter controling adaptivity of the Runge-Kutta-Merson solver.]; - string time-function("time-independent") [Time function.]; - string analytic-space-function(!) [Analytic space solution.]; - real amplitude(1.0) [Amplitude of boundary and analytic function.]; - real wave-length(1.0) [Wave length of 1D boundary and 1D analytic function.]; - real wave-length-x(1.0) [Wave length in x-axis of boundary and analytic function.]; - real wave-length-y(1.0) [Wave length in y-axis of boundary and analytic function.]; - real wave-length-z(1.0) [Wave length in z-axis of boundary and analytic function.]; - real waves-number(0.0) [Number of waves]; - real waves-number-x(0.0) [Number of waves in x-axis]; - real waves-number-y(0.0) [Number of waves in y-axis]; - real waves-number-z(0.0) [Number of waves in z-axis]; - real phase(0.0) [Phase of 1D boundary and 1D analytic function.]; - real phase-x(0.0) [Phase in x-axis of boundary and analytic function.]; - real phase-y(0.0) [Phase in y-axis of boundary and analytic function.]; - real phase-z(0.0) [Phase in z-axis of boundary and analytic function.]; - real sigma(1.0) [Sigma.]; - real initial-tau(1.0e-5) [Initial time step for the time dependent PDE solver. It can be changed if an adaptive solver is used.]; - real snapshot-period(!) [Time period for writing a state of the time dependent problem to a file.]; - real final-time(!) [Stop time of the time dependent simulation.]; - integer verbose(1) [Set the verbose mode. The higher number the more messages are generated.]; - integer laplace-convergence-test(0) [Set 1 if you want compare analytic and numerical Laplace operator in diff program]; - integer solution-convergence-test(0) [Set 1 if you want compare analytic and numerical solution of equation for test functions]; -},[The solver set-up.]; diff --git a/examples/heat-equation/heatEquationConfig.h b/examples/heat-equation/heatEquationConfig.h deleted file mode 100644 index 1997d4b95717d717cbf1ac94aa48b777dc5e8e5b..0000000000000000000000000000000000000000 --- a/examples/heat-equation/heatEquationConfig.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************** - heatEquationConfig.h - description - ------------------- - begin : Jul 8, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/*************************************************************************** - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef HEATEQUATIONCONFIG_H_ -#define HEATEQUATIONCONFIG_H_ - -#include <config/tnlConfigDescription.h> - -template< typename ConfigTag > -class heatEquationConfig -{ - public: - static void configSetup( tnlConfigDescription& config ) - { - config.addDelimiter( "Heat equation settings:" ); - config.addDelimiter( "Tests setting::" ); - config.addEntry < bool >( "approximation-test", "Test of the Laplace operator approximation.", false ); - config.addEntry < bool >( "eoc-test", "Test of the numerical scheme convergence.", false ); - config.addEntry < tnlString >( "test-function", "Testing function.", "sin-wave" ); - config.addEntryEnum( "sin-wave" ); - config.addEntryEnum( "sin-bumps" ); - config.addEntryEnum( "exp-bump" ); - config.addEntry < double >( "wave-length", "Wave length of the sine based test functions.", 1.0 ); - config.addEntry < double >( "wave-length-x", "Wave length of the sine based test functions.", 1.0 ); - config.addEntry < double >( "wave-length-y", "Wave length of the sine based test functions.", 1.0 ); - config.addEntry < double >( "wave-length-z", "Wave length of the sine based test functions.", 1.0 ); - config.addEntry < double >( "phase", "Phase of the sine based test functions.", 0.0 ); - config.addEntry < double >( "phase-x", "Phase of the sine based test functions.", 0.0 ); - config.addEntry < double >( "phase-y", "Phase of the sine based test functions.", 0.0 ); - config.addEntry < double >( "phase-z", "Phase of the sine based test functions.", 0.0 ); - config.addEntry < double >( "amplitude", "Amplitude length of the sine based test functions.", 1.0 ); - config.addEntry < double >( "waves-number", "Cut-off for the sine based test functions.", 0.0 ); - config.addEntry < double >( "waves-number-x", "Cut-off for the sine based test functions.", 0.0 ); - config.addEntry < double >( "waves-number-y", "Cut-off for the sine based test functions.", 0.0 ); - config.addEntry < double >( "waves-number-z", "Cut-off for the sine based test functions.", 0.0 ); - config.addEntry < double >( "sigma", "Sigma for the exp based test functions.", 1.0 ); - config.addEntry < tnlString >( "test-function-time-dependence", "Time dependence of the test function.", "none" ); - config.addEntryEnum( "none" ); - config.addEntryEnum( "linear" ); - config.addEntryEnum( "quadratic" ); - config.addEntryEnum( "cosine" ); - } -}; - -#endif /* HEATEQUATIONCONFIG_H_ */ diff --git a/examples/heat-equation/heatEquationScheme_impl.h b/examples/heat-equation/heatEquationScheme_impl.h index adb74db71dd1efb9563b87efe8e5a32ff3dd51bf..f4e8ff6ba947847d7081cf4c16199e3883cb2562 100644 --- a/examples/heat-equation/heatEquationScheme_impl.h +++ b/examples/heat-equation/heatEquationScheme_impl.h @@ -37,7 +37,7 @@ explicitUpdate( const RealType& time, { this->differentialOperator.explicitUpdate( time, tau, mesh, cellIndex, coordinates, u, fu ); VertexType vertex = mesh.getCellCenter( coordinates ); - fu[ cellIndex ] += this->rightHandSide.getValue( vertex ); + fu[ cellIndex ] += this->rightHandSide.getValue( time, vertex ); } #endif /* HEATEQUATIONSCHEME_IMPL_H_ */ diff --git a/examples/heat-equation/heatEquationSetter.h b/examples/heat-equation/heatEquationSetter.h index 10b011ed4eb08191e1007308c997a36063520a26..18a81da089d7a747712e2814b69c3cfdf4e329f9 100644 --- a/examples/heat-equation/heatEquationSetter.h +++ b/examples/heat-equation/heatEquationSetter.h @@ -25,9 +25,9 @@ #include <functions/tnlExpBumpFunction.h> #include <functions/tnlSinBumpsFunction.h> #include "tnlTimeFunction.h" -#include "tnlDirichletBoundaryConditions.h" -#include <schemes/diffusion/tnlLinearDiffusion.h> -#include "tnlNeumannBoundaryConditions.h" +#include <operators/tnlDirichletBoundaryConditions.h> +#include <operators/diffusion/tnlLinearDiffusion.h> +#include <operators/tnlNeumannBoundaryConditions.h> #include "tnlZeroRightHandSide.h" #include "tnlRightHandSide.h" diff --git a/examples/heat-equation/heatEquationSetter_impl.h b/examples/heat-equation/heatEquationSetter_impl.h index ed7910d468e4fd395f2884958c4612ba15d5bf6d..6c832456ebcb08051a9c55e6c681f37efea9b915 100644 --- a/examples/heat-equation/heatEquationSetter_impl.h +++ b/examples/heat-equation/heatEquationSetter_impl.h @@ -21,8 +21,8 @@ #include "heatEquationSetter.h" #include "heatEquationSolver.h" #include <functions/tnlTestFunction.h> -#include <schemes/diffusion/tnlLinearDiffusion.h> -#include "tnlDirichletBoundaryConditions.h" +#include <operators/diffusion/tnlLinearDiffusion.h> +#include <operators/tnlDirichletBoundaryConditions.h> #include "tnlRightHandSide.h" template< typename Real, diff --git a/examples/heat-equation/heatEquationSolver.h b/examples/heat-equation/heatEquationSolver.h index f1cd6169e940630314ff857468b366ed08833a5d..fa7b5a604c78b30e8f9c7a580114e0b53fe9e208 100644 --- a/examples/heat-equation/heatEquationSolver.h +++ b/examples/heat-equation/heatEquationSolver.h @@ -27,7 +27,6 @@ #include <solvers/pde/tnlExplicitUpdater.h> #include "heatEquationSolver.h" #include "heatEquationScheme.h" -#include "tnlAnalyticSolution.h" template< typename Mesh, @@ -81,16 +80,15 @@ class heatEquationSolver protected: - tnlSharedVector< RealType, DeviceType, IndexType > numericalSolution, - exactSolution, - analyticLaplace, - numericalLaplace; + tnlSharedVector< RealType, DeviceType, IndexType > solution; - tnlExplicitUpdater< Mesh, DofVectorType, BoundaryCondition, Scheme > explicitUpdater; + tnlExplicitUpdater< Mesh, DofVectorType, DifferentialOperator, BoundaryCondition, RightHandSide > explicitUpdater; + + DifferentialOperator differentialOperator; BoundaryCondition boundaryCondition; - Scheme scheme; + RightHandSide rightHandSide; }; #include "heatEquationSolver_impl.h" diff --git a/examples/heat-equation/heatEquationSolver_impl.h b/examples/heat-equation/heatEquationSolver_impl.h index 952299864266be1bc36b6ba159042ecc91473eb1..31c0234d1b5ad1ae70940c3578d4a0c6c4b42efd 100644 --- a/examples/heat-equation/heatEquationSolver_impl.h +++ b/examples/heat-equation/heatEquationSolver_impl.h @@ -48,21 +48,9 @@ template< typename Mesh, typename Diffusion, typename BoundaryCondition, typenam bool heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide > :: init( const tnlParameterContainer& parameters ) { - if( ! boundaryCondition.init( parameters ) ) + if( ! boundaryCondition.init( parameters ) || + ! rightHandSide.init( parameters ) ) return false; - /*analyticSpaceFunction.init(parameters); - ifLaplaceCompare = parameters.GetParameter< IndexType >( "approximation-test" ); - if((ifLaplaceCompare != 0) && (ifLaplaceCompare != 1)) - { - cerr << "Unknown value of laplace-convergence-test parameter. Valid values are 0 or 1. You set " << ifLaplaceCompare << ". "; - return false; - } - ifSolutionCompare = parameters.GetParameter< IndexType >("eoc-test"); - if((ifSolutionCompare != 0) && (ifSolutionCompare != 1)) - { - cerr << "Unknown value of solution-convergence-test parameter. Valid values are 0 or 1. You set " << ifSolutionCompare << ". "; - return false; - }*/ return true; } @@ -102,7 +90,7 @@ bindDofs( const MeshType& mesh, DofVectorType& dofVector ) { const IndexType dofs = mesh.getNumberOfCells(); - this->numericalSolution.bind( dofVector.getData(), dofs ); + this->solution.bind( dofVector.getData(), dofs ); } template< typename Mesh, @@ -114,10 +102,6 @@ heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide >:: bindAuxiliaryDofs( const MeshType& mesh, DofVectorType& auxiliaryDofVector ) { - const IndexType dofs = mesh.getNumberOfCells(); - this->exactSolution.bind( auxiliaryDofVector.getData(), dofs ); - this->analyticLaplace.bind( &auxiliaryDofVector.getData()[ dofs ], dofs ); - this->numericalLaplace.bind( &auxiliaryDofVector.getData()[ 2*dofs ], dofs ); } @@ -127,15 +111,11 @@ bool heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide > const MeshType& mesh ) { const tnlString& initialConditionFile = parameters.GetParameter< tnlString >( "initial-condition" ); - if( ! this->numericalSolution.load( initialConditionFile ) ) + if( ! this->solution.load( initialConditionFile ) ) { cerr << "I am not able to load the initial condition from the file " << initialConditionFile << "." << endl; return false; } - - //boundaryCondition.applyBoundaryConditions(mesh,numericalSolution,0.0,timeFunction,analyticSpaceFunction); - //timeFunction.applyInitTimeValues( numericalSolution); - return true; } @@ -154,35 +134,9 @@ makeSnapshot( const RealType& time, cout << endl << "Writing output at time " << time << " step " << step << "." << endl; tnlString fileName; - FileNameBaseNumberEnding( "numericalSolution-", step, 5, ".tnl", fileName ); - if( ! this->numericalSolution.save( fileName ) ) + FileNameBaseNumberEnding( "u-", step, 5, ".tnl", fileName ); + if( ! this->solution.save( fileName ) ) return false; - - /*if( ifSolutionCompare == 1) - { - analyticSolution.computeAnalyticSolution( mesh, time, exactSolution, timeFunction, analyticSpaceFunction ); - FileNameBaseNumberEnding( "analyticSolution-", step, 5, ".tnl", fileName ); - if( ! this->exactSolution. save( fileName ) ) - return false; - } - - if(ifLaplaceCompare == 1) - { - analyticSolution.computeLaplace( mesh, time, analyticLaplace, timeFunction, analyticSpaceFunction ); - //diffusion.getExplicitRHS( mesh, numericalSolution, numericalLaplace ); - - tnlString fileName; - FileNameBaseNumberEnding( "analyticLaplace", 0, 1, ".tnl", fileName ); - if( ! this -> analyticLaplace. save( fileName ) ) - return false; - - FileNameBaseNumberEnding( "numericalLaplace", 0, 1, ".tnl", fileName ); - if( ! this -> numericalLaplace. save( fileName ) ) - return false; - - exit(0); - }*/ - return true; } @@ -207,8 +161,9 @@ void heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide > explicitUpdater.template update< Mesh::Dimensions >( time, tau, mesh, + this->differentialOperator, this->boundaryCondition, - this->scheme, + this->rightHandSide, _u, _fu ); } diff --git a/examples/heat-equation/run-heat-equation-testy-konvergence b/examples/heat-equation/run-heat-equation-testy-konvergence deleted file mode 100644 index 2f71cca49f2e0f67c473ad2f56af1d4ec227ec32..0000000000000000000000000000000000000000 --- a/examples/heat-equation/run-heat-equation-testy-konvergence +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash - -dofSize=64 -dimension=2 -proportions=1 - -analyticFunction="exp-bump" -timeFunction="cosinus" - -amplitude=1.0 -waveLength=1.0 -waveLengthX=1.0 -waveLengthY=1.0 -waveLengthZ=1.0 -wavesNumber=0.0 -wavesNumberX=0.0 -wavesNumberY=0.0 -wavesNumberZ=0.0 -phase=0.0 -phaseX=0.0 -phaseY=0.0 -phaseZ=0.0 -sigma=1.0 - -tnl-grid-setup --dimensions ${dimension} \ - --proportions-x ${proportions} \ - --proportions-y ${proportions} \ - --proportions-z ${proportions} \ - --origin-x 0 \ - --origin-y 0 \ - --origin-z 0 \ - --size-x ${dofSize} \ - --size-y ${dofSize} \ - --size-z ${dofSize} \ - -tnl-discrete --mesh mesh.tnl \ - --function ${analyticFunction} \ - --output-file u-ini.tnl \ - --amplitude ${amplitude} \ - --wave-length ${waveLength} \ - --wave-length-x ${waveLengthX} \ - --wave-length-y ${waveLengthY} \ - --wave-length-z ${waveLengthZ} \ - --waves-number ${wavesNumber} \ - --waves-number-x ${wavesNumberX} \ - --waves-number-y ${wavesNumberY} \ - --waves-number-z ${wavesNumberZ} \ - --phase ${phase} \ - --phase-x ${phaseX} \ - --phase-y ${phaseY} \ - --phase-z ${phaseZ} \ - --sigma ${sigma} \ - -./heat-equation --dimensions ${dimension} \ - --time-discretisation explicit \ - --discrete-solver merson \ - --time-function ${timeFunction}\ - --analytic-space-function ${analyticFunction}\ - --amplitude ${amplitude} \ - --wave-length ${waveLength} \ - --wave-length-x ${waveLengthX} \ - --wave-length-y ${waveLengthY} \ - --wave-length-z ${waveLengthZ} \ - --waves-number ${wavesNumber} \ - --waves-number-x ${wavesNumberX} \ - --waves-number-y ${wavesNumberY} \ - --waves-number-z ${wavesNumberZ} \ - --phase ${phase} \ - --phase-x ${phaseX} \ - --phase-y ${phaseY} \ - --phase-z ${phaseZ} \ - --sigma ${sigma} \ - --snapshot-period 0.05 \ - --final-time 1.0 \ - --solution-convergence-test 1 \ - -rm u-ini.tnl - -tnl-diff --mesh mesh.tnl \ - --input-files numericalSolution-*.tnl analyticSolution-*.tnl \ - --mode halves \ - --output-file ${dofSize}-dofs \ - -rm *.tnl diff --git a/examples/heat-equation/run-heat-equation-testy-laplace-konvergence b/examples/heat-equation/run-heat-equation-testy-laplace-konvergence deleted file mode 100644 index 96d1ec835e84d590367c13caea81649a83fa251b..0000000000000000000000000000000000000000 --- a/examples/heat-equation/run-heat-equation-testy-laplace-konvergence +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash - -dofSize=8192 -dimension=1 -proportions=1 - -analyticFunction="exp-bump" -timeFunction="cosinus" - -amplitude=1.0 -waveLength=1.0 -waveLengthX=1.0 -waveLengthY=1.0 -waveLengthZ=1.0 -wavesNumber=0.0 -wavesNumberX=0.0 -wavesNumberY=0.0 -wavesNumberZ=0.0 -phase=0.0 -phaseX=0.0 -phaseY=0.0 -phaseZ=0.0 -sigma=1.0 - -tnl-grid-setup --dimensions ${dimension} \ - --proportions-x ${proportions} \ - --proportions-y ${proportions} \ - --proportions-z ${proportions} \ - --origin-x 0 \ - --origin-y 0 \ - --origin-z 0 \ - --size-x ${dofSize} \ - --size-y ${dofSize} \ - --size-z ${dofSize} \ - -tnl-discrete --mesh mesh.tnl \ - --function ${analyticFunction} \ - --output-file u-ini.tnl \ - --amplitude ${amplitude} \ - --wave-length ${waveLength} \ - --wave-length-x ${waveLengthX} \ - --wave-length-y ${waveLengthY} \ - --wave-length-z ${waveLengthZ} \ - --waves-number ${wavesNumber} \ - --waves-number-x ${wavesNumberX} \ - --waves-number-y ${wavesNumberY} \ - --waves-number-z ${wavesNumberZ} \ - --phase ${phase} \ - --phase-x ${phaseX} \ - --phase-y ${phaseY} \ - --phase-z ${phaseZ} \ - --sigma ${sigma} \ - -./heat-equation --dimensions ${dimension} \ - --time-discretisation explicit \ - --discrete-solver merson \ - --time-function ${timeFunction}\ - --analytic-space-function ${analyticFunction}\ - --amplitude ${amplitude} \ - --wave-length ${waveLength} \ - --wave-length-x ${waveLengthX} \ - --wave-length-y ${waveLengthY} \ - --wave-length-z ${waveLengthZ} \ - --waves-number ${wavesNumber} \ - --waves-number-x ${wavesNumberX} \ - --waves-number-y ${wavesNumberY} \ - --waves-number-z ${wavesNumberZ} \ - --phase ${phase} \ - --phase-x ${phaseX} \ - --phase-y ${phaseY} \ - --phase-z ${phaseZ} \ - --sigma ${sigma} \ - --snapshot-period 0.05 \ - --final-time 1.0 \ - --laplace-convergence-test 1 \ - -rm u-ini.tnl - -tnl-diff --mesh mesh.tnl \ - --input-files analyticLaplace*.tnl numericalLaplace*.tnl \ - --mode halves \ - --output-file laplceDiff-${dofSize}-dofs \ - -rm *.tnl diff --git a/examples/heat-equation/tnl-heat-equation-eoc.cpp b/examples/heat-equation/tnl-heat-equation-eoc.cpp new file mode 100644 index 0000000000000000000000000000000000000000..418c4fc5f616d6a24dd52bc6fd3f1a2fdcc06356 --- /dev/null +++ b/examples/heat-equation/tnl-heat-equation-eoc.cpp @@ -0,0 +1,82 @@ +/*************************************************************************** + tnl-heat-equation-eoc.cpp - description + ------------------- + begin : Sep 7, 2014 + copyright : (C) 2014 by oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <solvers/tnlSolver.h> +#include <solvers/tnlFastBuildConfig.h> +#include <solvers/tnlConfigTags.h> +#include <functions/tnlTestFunction.h> +#include <operators/diffusion/tnlLinearDiffusion.h> +#include <operators/diffusion/tnlExactLinearDiffusion.h> +#include <operators/tnlDirichletBoundaryConditions.h> +#include "tnlHeatEquationEocRhs.h" +#include "heatEquationSolver.h" + +//typedef tnlDefaultConfigTag BuildConfig; +typedef tnlFastBuildConfig BuildConfig; + +template< typename ConfigTag > +class heatEquationEocConfig +{ + public: + static void configSetup( tnlConfigDescription& config ) + { + config.addDelimiter( "Heat equation EOC settings:" ); + config.addDelimiter( "Tests setting::" ); + tnlTestFunction< 3, double >::configSetup( config ); + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter > +class heatEquationSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef tnlStaticVector< MeshType::Dimensions, Real > Vertex; + + static bool run( const tnlParameterContainer& parameters ) + { + enum { Dimensions = MeshType::Dimensions }; + typedef tnlLinearDiffusion< MeshType, Real, Index > ApproximateOperator; + typedef tnlExactLinearDiffusion< Dimensions > ExactOperator; + typedef tnlTestFunction< MeshType::Dimensions, Real, Device > TestFunction; + typedef tnlHeatEquationEocRhs< ExactOperator, TestFunction > RightHandSide; + typedef tnlStaticVector < MeshType::Dimensions, Real > Vertex; + typedef tnlDirichletBoundaryConditions< MeshType, TestFunction, Real, Index > BoundaryConditions; + typedef heatEquationSolver< MeshType, ApproximateOperator, BoundaryConditions, RightHandSide > Solver; + SolverStarter solverStarter; + return solverStarter.template run< Solver >( parameters ); + }; +}; + +int main( int argc, char* argv[] ) +{ + tnlSolver< heatEquationSetter, heatEquationEocConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +} + + diff --git a/examples/heat-equation/main.cpp b/examples/heat-equation/tnl-heat-equation.cpp similarity index 84% rename from examples/heat-equation/main.cpp rename to examples/heat-equation/tnl-heat-equation.cpp index 95947d2651055077eae464a21f416cac17430c79..ce8555dac439a76c4e859422576ae7d9e4b8cb6e 100644 --- a/examples/heat-equation/main.cpp +++ b/examples/heat-equation/tnl-heat-equation.cpp @@ -16,7 +16,6 @@ ***************************************************************************/ #include "heatEquationSetter.h" -#include "heatEquationConfig.h" #include <solvers/tnlSolver.h> #include <solvers/tnlFastBuildConfig.h> #include <solvers/tnlConfigTags.h> @@ -24,6 +23,17 @@ //typedef tnlDefaultConfigTag BuildConfig; typedef tnlFastBuildConfig BuildConfig; +template< typename ConfigTag > +class heatEquationConfig +{ + public: + static void configSetup( tnlConfigDescription& config ) + { + config.addDelimiter( "Heat equation settings:" ); + config.addDelimiter( "Tests setting::" ); + } +}; + int main( int argc, char* argv[] ) { tnlSolver< heatEquationSetter, heatEquationConfig, BuildConfig > solver; diff --git a/examples/heat-equation/run-heat-equation b/examples/heat-equation/tnl-run-heat-equation similarity index 100% rename from examples/heat-equation/run-heat-equation rename to examples/heat-equation/tnl-run-heat-equation diff --git a/examples/heat-equation/tnl-run-heat-equation-eoc-test b/examples/heat-equation/tnl-run-heat-equation-eoc-test new file mode 100644 index 0000000000000000000000000000000000000000..cec1fa19dd4d4b71b557b1aa349b96c77a7585f7 --- /dev/null +++ b/examples/heat-equation/tnl-run-heat-equation-eoc-test @@ -0,0 +1,151 @@ +#!/bin/bash + +solverName="tnl-heat-equation-eoc-test" +device="host" +dimensions="1D 2D 3D" +sizes1D="16 32 64 128 256 512" +sizes2D="16 32 64 128 256 512" +sizes3D="16 32 64 128" +testFunctions="exp-bump" +snapshotPeriod=0.1 +finalTime=1 + +setupTestFunction() +{ + testFunction=$1 + if test x${testFunction} = "xexp-bump"; + then + origin=-1.0 + proportions=2.0 + amplitude=1.0 + waveLength=1.0 + waveLengthX=1.0 + waveLengthY=1.0 + waveLengthZ=1.0 + wavesNumber=0.0 + wavesNumberX=0.0 + wavesNumberY=0.0 + wavesNumberZ=0.0 + phase=0.0 + phaseX=0.0 + phaseY=0.0 + phaseZ=0.0 + sigma=0.5 + fi +} + +setupGrid() +{ + dimensions=$1 + gridSize=$2 + tnl-grid-setup --dimensions ${dimensions} \ + --origin-x ${origin} \ + --origin-y ${origin} \ + --origin-z ${origin} \ + --proportions-x ${proportions} \ + --proportions-y ${proportions} \ + --proportions-z ${proportions} \ + --size-x ${gridSize} \ + --size-y ${gridSize} \ + --size-z ${gridSize} +} + +setInitialCondition() +{ + testFunction=$1 + tnl-init --function ${testFunction} \ + --output-file init.tnl \ + --amplitude ${amplitude} \ + --wave-length ${waveLength} \ + --wave-length-x ${waveLengthX} \ + --wave-length-y ${waveLengthY} \ + --wave-length-z ${waveLengthZ} \ + --waves-number ${wavesNumber} \ + --waves-number-x ${wavesNumberX} \ + --waves-number-y ${wavesNumberY} \ + --waves-number-z ${wavesNumberZ} \ + --phase ${phase} \ + --phase-x ${phaseX} \ + --phase-y ${phaseY} \ + --phase-z ${phaseZ} \ + --sigma ${sigma} +} + +solve() +{ + timeDiscretisation=$1 + discreteSolver=$2 + ${solverName} --mesh mesh.tnl \ + --time-discretisation ${timeDiscretisation} \ + --discrete-solver ${discreteSolver} \ + --test-function ${testFunction}\ + --amplitude ${amplitude} \ + --wave-length ${waveLength} \ + --wave-length-x ${waveLengthX} \ + --wave-length-y ${waveLengthY} \ + --wave-length-z ${waveLengthZ} \ + --waves-number ${wavesNumber} \ + --waves-number-x ${wavesNumberX} \ + --waves-number-y ${wavesNumberY} \ + --waves-number-z ${wavesNumberZ} \ + --phase ${phase} \ + --phase-x ${phaseX} \ + --phase-y ${phaseY} \ + --phase-z ${phaseZ} \ + --sigma ${sigma} \ + --snapshot-period ${snapshotPeriod} \ + --final-time ${finalTime} +} + +computeError() +{ + + tnl-diff --mesh mesh.tnl \ + --input-files numericalSolution-*.tnl analyticSolution-*.tnl \ + --mode halves \ + --output-file ${dofSize}-dofs +} + +runTest() +{ + for testFunction in ${testFunctions}; + do + mkdir -p ${testFunction} + cd ${testFunction} + setupTestFunction ${testFunction} + + for dim in ${dimensions}; + do + mkdir -p $dim + cd ${dim} + if test $dim = 1D; + then + sizes=$sizes1D + fi + if test $dim = 2D; + then + sizes=$sizes2D + fi + if test $dim = 3D; + then + sizes=$sizes3D + fi + + for size in $sizes; + do + mkdir -p $size + cd $size + setupGrid $dim $size + setInitialCondition $testFunction + solve explicit merson + cd .. + done + + cd .. + done + cd .. + done +} + +runTest + diff --git a/examples/heat-equation/tnlAnalyticSolution.h b/examples/heat-equation/tnlAnalyticSolution.h deleted file mode 100644 index 486b46d50f888f4939763f6d4e3b9b618dc4350e..0000000000000000000000000000000000000000 --- a/examples/heat-equation/tnlAnalyticSolution.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef TNLANALYTICSOLUTION_H -#define TNLANALYTICSOLUTION_H - -template< typename Mesh, - typename Real, - typename Index > -class AnalyticSolution -{ - -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class AnalyticSolution< tnlGrid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef tnlGrid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - //typedef tnlSharedVector< RealType, DeviceType, IndexType > SharedVector; - //typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; - typedef tnlStaticVector< 1, RealType > VertexType; - - template< typename TimeFunction, - typename AnalyticSpaceFunction, - typename Vector > - void computeAnalyticSolution( const MeshType& mesh, - const RealType& time, - Vector& output, - const TimeFunction timeFunction, - const AnalyticSpaceFunction analyticSpaceFunction ); - - template< typename TimeFunction, - typename AnalyticSpaceFunction, - typename Vector > - void computeLaplace( const MeshType& mesh, - const RealType& time, - Vector& output, - const TimeFunction timeFunction, - const AnalyticSpaceFunction analyticSpaceFunction ); -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class AnalyticSolution< tnlGrid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef tnlGrid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - //typedef tnlSharedVector< RealType, DeviceType, IndexType > SharedVector; - //typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; - typedef tnlStaticVector< 2, RealType > VertexType; - - template< typename TimeFunction, - typename AnalyticSpaceFunction, - typename Vector > - void computeAnalyticSolution( const MeshType& mesh, - const RealType& time, - Vector& output, - const TimeFunction timeFunction, - const AnalyticSpaceFunction analyticSpaceFunction ); - - template< typename TimeFunction, - typename AnalyticSpaceFunction, - typename Vector > - void computeLaplace( const MeshType& mesh, - const RealType& time, - Vector& output, - const TimeFunction timeFunction, - const AnalyticSpaceFunction analyticSpaceFunction ); -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class AnalyticSolution< tnlGrid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef tnlGrid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - typedef tnlSharedVector< RealType, DeviceType, IndexType > SharedVector; - typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; - typedef tnlStaticVector< 3, RealType > VertexType; - - template< typename TimeFunction, - typename AnalyticSpaceFunction, - typename Vector > - void computeAnalyticSolution( const MeshType& mesh, - const RealType& time, - Vector& output, - const TimeFunction timeFunction, - const AnalyticSpaceFunction analyticSpaceFunction ); - - template< typename TimeFunction, - typename AnalyticSpaceFunction, - typename Vector > - void computeLaplace( const MeshType& mesh, - const RealType& time, - Vector& output, - const TimeFunction timeFunction, - const AnalyticSpaceFunction analyticSpaceFunction ); -}; - -#include "tnlAnalyticSolution_impl.h" - -#endif /* TNLANALYTICSOLUTION_H */ diff --git a/examples/heat-equation/tnlAnalyticSolution_impl.h b/examples/heat-equation/tnlAnalyticSolution_impl.h deleted file mode 100644 index 37ff1ba41c0427180ffae8e4fd53883b2f5973cc..0000000000000000000000000000000000000000 --- a/examples/heat-equation/tnlAnalyticSolution_impl.h +++ /dev/null @@ -1,222 +0,0 @@ -#ifndef TNLANALYTICSOLUTION_IMPL_H -#define TNLANALYTICSOLUTION_IMPL_H - -#include "tnlAnalyticSolution.h" - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -template< typename TimeFunction, - typename AnalyticSpaceFunction, - typename Vector > -void -AnalyticSolution< tnlGrid< 1, MeshReal, Device, MeshIndex >, Real, Index >:: -computeAnalyticSolution( const MeshType& mesh, - const RealType& time, - Vector& output, - const TimeFunction timeFunction, - const AnalyticSpaceFunction analyticSpaceFunction ) -{ - RealType timeFunctionValue = timeFunction.getTimeValue(time); - - VertexType vertex; - CoordinatesType coordinates; - - for(IndexType i=0; i<output.getSize(); i++) - { - coordinates = mesh.getCellCoordinates( i ); - vertex = mesh.getCellCenter( coordinates ); - - output[i] = timeFunctionValue*analyticSpaceFunction.getF( vertex ); - } -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -template< typename TimeFunction, - typename AnalyticSpaceFunction, - typename Vector > -void -AnalyticSolution< tnlGrid< 1, MeshReal, Device, MeshIndex >, Real, Index >:: -computeLaplace( const MeshType& mesh, - const RealType& time, - Vector& output, - const TimeFunction timeFunction, - const AnalyticSpaceFunction analyticSpaceFunction ) -{ - RealType timeFunctionValue = timeFunction.getTimeValue(time); - - VertexType vertex; - CoordinatesType coordinates; - - #ifdef HAVE_OPENMP - #pragma omp parallel for private(coordinates,vertex) - #endif - for(IndexType i=1; i<(output.getSize()-1); i++) - { - coordinates = mesh.getCellCoordinates( i ); - vertex = mesh.getCellCenter( coordinates ); - - output[i] = timeFunctionValue*analyticSpaceFunction.template getF<2,0,0>(vertex); - } -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -template< typename TimeFunction, - typename AnalyticSpaceFunction, - typename Vector > -void -AnalyticSolution< tnlGrid< 2, MeshReal, Device, MeshIndex >, Real, Index >:: -computeAnalyticSolution( const MeshType& mesh, - const RealType& time, - Vector& output, - const TimeFunction timeFunction, - const AnalyticSpaceFunction analyticSpaceFunction ) -{ - RealType timeFunctionValue = timeFunction.getTimeValue(time); - - VertexType vertex; - CoordinatesType coordinates; - - #ifdef HAVE_OPENMP - #pragma omp parallel for private(coordinates,vertex) - #endif - for(IndexType i=0; i<output.getSize(); i++) - { - coordinates = mesh.getCellCoordinates( i ); - vertex = mesh.getCellCenter( coordinates ); - - output[i] = timeFunctionValue*analyticSpaceFunction.getF(vertex); - } - -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -template< typename TimeFunction, - typename AnalyticSpaceFunction, - typename Vector > -void -AnalyticSolution< tnlGrid< 2, MeshReal, Device, MeshIndex >, Real, Index >:: -computeLaplace( const MeshType& mesh, - const RealType& time, - Vector& output, - const TimeFunction timeFunction, - const AnalyticSpaceFunction analyticSpaceFunction ) -{ - RealType timeFunctionValue = timeFunction.getTimeValue(time); - - VertexType vertex; - CoordinatesType coordinates; - CoordinatesType dimensions = mesh.getDimensions(); - - #ifdef HAVE_OPENMP - #pragma omp parallel for private(coordinates,vertex) - #endif - for(IndexType i=1; i<(dimensions.x()-1); i++) - { - for(IndexType j=1; j<(dimensions.y()-1); j++) - { - coordinates.x()=i; - coordinates.y()=j; - - vertex = mesh.getCellCenter( coordinates ); - - output[j*mesh.getDimensions().x()+i] = - timeFunctionValue*(analyticSpaceFunction.template getF<2,0,0>(vertex)+ - analyticSpaceFunction.template getF<0,2,0>(vertex)); - } - } -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -template< typename TimeFunction, - typename AnalyticSpaceFunction, - typename Vector > -void -AnalyticSolution< tnlGrid< 3, MeshReal, Device, MeshIndex >, Real, Index >:: -computeAnalyticSolution( const MeshType& mesh, - const RealType& time, - Vector& output, - const TimeFunction timeFunction, - const AnalyticSpaceFunction analyticSpaceFunction ) -{ - RealType timeFunctionValue = timeFunction.getTimeValue(time); - - VertexType vertex; - CoordinatesType coordinates; - - #ifdef HAVE_OPENMP - #pragma omp parallel for private(coordinates,vertex) - #endif - for(IndexType i=0; i<output.getSize(); i++) - { - coordinates = mesh.getCellCoordinates( i ); - vertex = mesh.getCellCenter( coordinates ); - - output[i] = timeFunctionValue*analyticSpaceFunction.getF(vertex); - } -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -template< typename TimeFunction, - typename AnalyticSpaceFunction, - typename Vector > -void -AnalyticSolution< tnlGrid< 3, MeshReal, Device, MeshIndex >, Real, Index >:: -computeLaplace( const MeshType& mesh, - const RealType& time, - Vector& output, - const TimeFunction timeFunction, - const AnalyticSpaceFunction analyticSpaceFunction ) -{ - RealType timeFunctionValue = timeFunction.getTimeValue(time); - - VertexType vertex; - CoordinatesType coordinates; - CoordinatesType dimensions = mesh.getDimensions(); - - #ifdef HAVE_OPENMP - #pragma omp parallel for private(coordinates,vertex) - #endif - for(IndexType i=1; i<(dimensions.x()-1); i++) - { - for(IndexType j=1; j<(dimensions.y()-1); j++) - { - for(IndexType k=1; k<(dimensions.y()-1); k++) - { - coordinates.x()=i; - coordinates.y()=j; - coordinates.z()=k; - - vertex = mesh.getCellCenter( coordinates ); - - output[mesh.getCellIndex( CoordinatesType( i,j,k ) ) ] = - timeFunctionValue*(analyticSpaceFunction.template getF<2,0,0>(vertex)+ - analyticSpaceFunction.template getF<0,2,0>(vertex)+ - analyticSpaceFunction.template getF<0,0,2>(vertex)); - } - } - } -} -#endif /* TNLANALYTICSOLUTION_IMPL_H */ diff --git a/examples/heat-equation/tnlHeatEquationEocRhs.h b/examples/heat-equation/tnlHeatEquationEocRhs.h new file mode 100644 index 0000000000000000000000000000000000000000..d76ce11cecc4754b09b882bdd5bd2e95f3261d72 --- /dev/null +++ b/examples/heat-equation/tnlHeatEquationEocRhs.h @@ -0,0 +1,53 @@ +/*************************************************************************** + tnlHeatEquationEocRhs.h - description + ------------------- + begin : Sep 8, 2014 + copyright : (C) 2014 by oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TNLHEATEQUATIONEOCRHS_H_ +#define TNLHEATEQUATIONEOCRHS_H_ + +template< typename ExactOperator, + typename TestFunction > +class tnlHeatEquationEocRhs +{ + public: + + typedef ExactOperator ExactOperatorType; + typedef TestFunction TestFunctionType; + + bool init( const tnlParameterContainer& parameters ) + { + if( ! testFunction.init( parameters ) ) + return false; + return true; + }; + + template< typename Vertex, + typename Real > + Real getValue( const Vertex& vertex, + const Real& time ) + { + return testFunction.getTimeDerivative( vertex, time ) - exactOperator.getValue( testFunction, vertex, time ); + }; + + protected: + ExactOperator exactOperator; + + TestFunction testFunction; +}; + + + +#endif /* TNLHEATEQUATIONEOCRHS_H_ */ diff --git a/examples/heat-equation/tnlTimeFunction.h b/examples/heat-equation/tnlTimeFunction.h deleted file mode 100644 index fcc8a289f796ff56dcdfa9502415b1f8666061d2..0000000000000000000000000000000000000000 --- a/examples/heat-equation/tnlTimeFunction.h +++ /dev/null @@ -1,119 +0,0 @@ -#ifndef TNLTIMEFUNCTION_H -#define TNLTIMEFUNCTION_H - -class TimeFunctionBase -{ - public: - - enum TimeFunctionSet {TimeIndependent, Linear, Quadratic, Cosinus}; -}; - -template< typename Mesh, - TimeFunctionBase::TimeFunctionSet timefunction, - typename Real, - typename Index > -class TimeFunction -{ - -}; - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::TimeIndependent, - Real, Index >: public TimeFunctionBase -{ - public: - enum setTimeFunction{ TimeIndependent }; - typedef tnlGrid< Dim, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef Index IndexType; - typedef tnlSharedVector< RealType, DeviceType, IndexType > SharedVectorType; - typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; - - RealType getTimeValue(const RealType& time) const; - RealType getDerivation(const RealType& time) const; - void applyInitTimeValues(SharedVectorType& u) const; -}; - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::Linear, - Real, Index >: public TimeFunctionBase -{ - public: - enum setTimeFunction{ Linear }; - typedef tnlGrid< Dim, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef Index IndexType; - typedef tnlSharedVector< RealType, DeviceType, IndexType > SharedVectorType; - typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; - - RealType getTimeValue(const RealType& time) const; - RealType getDerivation(const RealType& time) const; - void applyInitTimeValues(SharedVectorType& u) const; -}; - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::Quadratic, - Real, Index >: public TimeFunctionBase -{ - public: - enum setTimeFunction{ Quadratic }; - typedef tnlGrid< Dim, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef Index IndexType; - typedef tnlSharedVector< RealType, DeviceType, IndexType > SharedVectorType; - typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; - - RealType getTimeValue(const RealType& time) const; - RealType getDerivation(const RealType& time) const; - void applyInitTimeValues(SharedVectorType& u) const; -}; - -template<> -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::Cosinus, - Real, Index >: public TimeFunctionBase -{ - public: - enum setTimeFunction{ Cosinus }; - typedef tnlGrid< Dim, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef Index IndexType; - typedef tnlSharedVector< RealType, DeviceType, IndexType > SharedVectorType; - typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; - - RealType getTimeValue(const RealType& time) const; - RealType getDerivation(const RealType& time) const; - void applyInitTimeValues(SharedVectorType& u) const; -}; - -#include "tnlTimeFunction_impl.h" - -#endif /* TNLTIMEFUNCTION_H */ diff --git a/examples/heat-equation/tnlTimeFunction_impl.h b/examples/heat-equation/tnlTimeFunction_impl.h deleted file mode 100644 index c357d148ece4458fa72e2b38112faec78cf969a7..0000000000000000000000000000000000000000 --- a/examples/heat-equation/tnlTimeFunction_impl.h +++ /dev/null @@ -1,198 +0,0 @@ -#ifndef TNLTIMEFUNCTION_IMPL_H -#define TNLTIMEFUNCTION_IMPL_H - -#include "tnlTimeFunction.h" - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -Real -TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::TimeIndependent, - Real, Index >:: -getTimeValue( const RealType& time ) const -{ - return 1.0; -} - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -Real -TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::Linear, - Real, Index >:: -getTimeValue( const RealType& time ) const -{ - return time; -} - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -Real -TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::Quadratic, - Real, Index >:: -getTimeValue( const RealType& time ) const -{ - return time*time; -} - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -Real -TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::Cosinus, - Real, Index >:: -getTimeValue( const RealType& time ) const -{ - return cos( time ); -} - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -Real -TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::TimeIndependent, - Real, Index >:: -getDerivation( const RealType& time ) const -{ - return 0.0; -} - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -Real -TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::Linear, - Real, Index >:: -getDerivation( const RealType& time ) const -{ - return 1.0; -} - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -Real -TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::Quadratic, - Real, Index >:: -getDerivation( const RealType& time ) const -{ - return 2.0*time; -} - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -Real -TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::Cosinus, - Real, Index >:: -getDerivation( const RealType& time ) const -{ - return -sin(time); -} - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -void -TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::TimeIndependent, - Real, Index >:: -applyInitTimeValues( SharedVectorType& u ) const -{ - -} - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -void -TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::Linear, - Real, Index >:: -applyInitTimeValues( SharedVectorType& u ) const -{ - #ifdef HAVE_OPENMP - #pragma omp parallel for - #endif - for(IndexType i=1; i<(u.getSize()-1); i++) - { - u[i] = 0; - } -} - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -void -TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::Quadratic, - Real, Index >:: -applyInitTimeValues( SharedVectorType& u ) const -{ - #ifdef HAVE_OPENMP - #pragma omp parallel for - #endif - for(IndexType i=1; i<(u.getSize()-1); i++) - { - u[i] = 0; - } -} - -template< int Dim, - typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -void -TimeFunction< tnlGrid< Dim, MeshReal, Device, MeshIndex >, - TimeFunctionBase::Cosinus, - Real, Index >:: -applyInitTimeValues( SharedVectorType& u ) const -{ - -} - -#endif /* TNLTIMEFUNCTION_IMPL_H */ diff --git a/examples/heat-equation/tnlZeroRightHandSide.h b/examples/heat-equation/tnlZeroRightHandSide.h deleted file mode 100644 index 7e7948223775b18df81bb374e48cda8463f19a5d..0000000000000000000000000000000000000000 --- a/examples/heat-equation/tnlZeroRightHandSide.h +++ /dev/null @@ -1,68 +0,0 @@ - -#ifndef TNLZERORIGHTHANDSIDE_H -#define TNLZERORIGHTHANDSIDE_H - -template<typename Mesh> -class tnlZeroRightHandSide -{ - -}; - -template<typename Real, typename Device, typename Index> -class tnlZeroRightHandSide<tnlGrid<1,Real,Device,Index>> { - - public: - - typedef tnlGrid<1,Real,Device,Index> MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; - - template<typename AnalyticSpaceFunction, typename TimeFunction> - void applyRHSValues(const MeshType& mesh, const RealType& time, DofVectorType& _fu, - TimeFunction& timeFunction, AnalyticSpaceFunction& analyticSpaceFunction); - -}; - -template<typename Real, typename Device, typename Index> -class tnlZeroRightHandSide<tnlGrid<2,Real,Device,Index>> { - - public: - - typedef tnlGrid<2,Real,Device,Index> MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; - - template<typename AnalyticSpaceFunction, typename TimeFunction> - void applyRHSValues(const MeshType& mesh, const RealType& time, DofVectorType& _fu, - TimeFunction& timeFunction, AnalyticSpaceFunction& analyticSpaceFunction); - -}; - -template<typename Real, typename Device, typename Index> -class tnlZeroRightHandSide<tnlGrid<3,Real,Device,Index>> { - - public: - - typedef tnlGrid<3,Real,Device,Index> MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; - - template<typename AnalyticSpaceFunction, typename TimeFunction> - void applyRHSValues(const MeshType& mesh, const RealType& time, DofVectorType& _fu, - TimeFunction& timeFunction, AnalyticSpaceFunction& analyticSpaceFunction); - -}; - -#include "tnlZeroRightHandSide_impl.h" - -#endif /* TNLZERORIGHTHANDSIDE_H */ - diff --git a/examples/heat-equation/tnlZeroRightHandSide_impl.h b/examples/heat-equation/tnlZeroRightHandSide_impl.h deleted file mode 100644 index c5e1aca3c1d72272a6d75c4071c7b6e14c4596e3..0000000000000000000000000000000000000000 --- a/examples/heat-equation/tnlZeroRightHandSide_impl.h +++ /dev/null @@ -1,35 +0,0 @@ - -#ifndef TNLZERORIGHTHANDSIDE_IMPL_H -#define TNLZERORIGHTHANDSIDE_IMPL_H - -#include "tnlZeroRightHandSide.h" - -template<typename Real, typename Device, typename Index> -template<typename AnalyticSpaceFunction, typename TimeFunction> -void tnlZeroRightHandSide<tnlGrid<1,Real,Device,Index>>:: -applyRHSValues(const MeshType& mesh, const RealType& time, DofVectorType& _fu, - TimeFunction& timeFunction, AnalyticSpaceFunction& analyticSpaceFunction) -{ - -} - -template<typename Real, typename Device, typename Index> -template<typename AnalyticSpaceFunction, typename TimeFunction> -void tnlZeroRightHandSide<tnlGrid<2,Real,Device,Index>>:: -applyRHSValues(const MeshType& mesh, const RealType& time, DofVectorType& _fu, - TimeFunction& timeFunction, AnalyticSpaceFunction& analyticSpaceFunction) -{ - -} - -template<typename Real, typename Device, typename Index> -template<typename AnalyticSpaceFunction, typename TimeFunction> -void tnlZeroRightHandSide<tnlGrid<3,Real,Device,Index>>:: -applyRHSValues(const MeshType& mesh, const RealType& time, DofVectorType& _fu, - TimeFunction& timeFunction, AnalyticSpaceFunction& analyticSpaceFunction) -{ - -} - -#endif /* TNLZERORIGHTHANDSIDE_IMPL_H */ - diff --git a/examples/navier-stokes/navierStokesSetter_impl.h b/examples/navier-stokes/navierStokesSetter_impl.h index cfe5cadaa2c3859227291787dbde658e0c2ec05e..0ef147df67ea0b4a492943f340a7b856f3d05483 100644 --- a/examples/navier-stokes/navierStokesSetter_impl.h +++ b/examples/navier-stokes/navierStokesSetter_impl.h @@ -20,8 +20,8 @@ #include <mesh/tnlGrid.h> #include <mesh/tnlLinearGridGeometry.h> -#include <schemes/euler/fvm/tnlLaxFridrichs.h> -#include <schemes/gradient/tnlCentralFDMGradient.h> +#include <operators/euler/fvm/tnlLaxFridrichs.h> +#include <operators/gradient/tnlCentralFDMGradient.h> template< typename MeshType, typename SolverStarter > template< typename RealType, diff --git a/examples/navier-stokes/navierStokesSolver.h b/examples/navier-stokes/navierStokesSolver.h index 9fe08ec3e313aeace13f239de6964187da3d4098..2bf0fa5becf90e6038f4c4f904365ffd90b81e19 100644 --- a/examples/navier-stokes/navierStokesSolver.h +++ b/examples/navier-stokes/navierStokesSolver.h @@ -25,9 +25,9 @@ #include <matrices/tnlCSRMatrix.h> #include <solvers/preconditioners/tnlDummyPreconditioner.h> #include <solvers/tnlSolverMonitor.h> -#include <schemes/euler/fvm/tnlLaxFridrichs.h> -#include <schemes/gradient/tnlCentralFDMGradient.h> -#include <schemes/diffusion/tnlLinearDiffusion.h> +#include <operators/euler/fvm/tnlLaxFridrichs.h> +#include <operators/gradient/tnlCentralFDMGradient.h> +#include <operators/diffusion/tnlLinearDiffusion.h> #include <mesh/tnlLinearGridGeometry.h> #include <solvers/cfd/navier-stokes/tnlNavierStokesSolver.h> diff --git a/install b/install index baaf73e4e4ed4f014491a58a3227692c167bc2a1..0c15ff9b1e3e6f64833becbfd12d2b004e53e2c2 100755 --- a/install +++ b/install @@ -29,7 +29,7 @@ ${CMAKE} .. -DCMAKE_BUILD_TYPE=Debug \ -DPETSC_DIR=${PETSC_DIR} \ -DWITH_TEMPLATE_EXPLICIT_INSTANTIATION=${TEMPLATE_EXPLICIT_INSTANTIATION} make -j${CPUS} ${VERBOSE} -#make -j${CPUS} test +make -j${CPUS} test make -j${CPUS} install cd ../Release @@ -38,6 +38,6 @@ ${CMAKE} .. -DCMAKE_INSTALL_PREFIX=${HOME}/local \ -DPETSC_DIR=${PETSC_DIR} \ -DWITH_TEMPLATE_EXPLICIT_INSTANTIATION=${TEMPLATE_EXPLICIT_INSTANTIATION} make -j${CPUS} ${VERBOSE} -#make -j${CPUS} test +make -j${CPUS} test make -j${CPUS} install diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ad9101d28d31236e48530397b1cfaff5f6b58435..748f71b7313cb85b5ef642512034b927f511d9db 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,18 +5,19 @@ ADD_SUBDIRECTORY( core ) ADD_SUBDIRECTORY( debug ) ADD_SUBDIRECTORY( matrices ) ADD_SUBDIRECTORY( mesh ) -ADD_SUBDIRECTORY( schemes ) +ADD_SUBDIRECTORY( operators ) ADD_SUBDIRECTORY( solvers ) ADD_SUBDIRECTORY( legacy ) ADD_SUBDIRECTORY( implementation ) -set( tnl_SOURCES ${tnl_generators_SOURCES} +set( tnl_SOURCES ${tnl_functions_SOURCES} ${tnl_config_SOURCES} ${tnl_core_SOURCES} ${tnl_implementation_SOURCES} ${tnl_legacy_SOURCES} ${tnl_debug_SOURCES} - ${tnl_matrices_SOURCES} ) + ${tnl_matrices_SOURCES} + ${tnl_operators_SOURCES} ) set( tnl_CUDA__SOURCES ${tnl_generators_CUDA__SOURCES} ${tnl_config_CUDA__SOURCES} @@ -24,7 +25,8 @@ set( tnl_CUDA__SOURCES ${tnl_generators_CUDA__SOURCES} ${tnl_implementation_CUDA__SOURCES} ${tnl_legacy_CUDA__SOURCES} ${tnl_debug_CUDA__SOURCES} - ${tnl_matrices_CUDA__SOURCES} ) + ${tnl_matrices_CUDA__SOURCES} + ${tnl_operators_CUDA__SOURCES} ) if( BUILD_CUDA ) diff --git a/src/config/tnlConfigEntry.h b/src/config/tnlConfigEntry.h index bd96061c40e01deba88a1173d5c7b2cadf77e896..e3c6f3b384afa796bd682310f12cb95c175d21d9 100644 --- a/src/config/tnlConfigEntry.h +++ b/src/config/tnlConfigEntry.h @@ -53,7 +53,7 @@ struct tnlConfigEntry : public tnlConfigEntryBase tnlString getEntryType() const { - return ::getParameterType< EntryType >(); + return ::getType< EntryType >(); } tnlString getUIEntryType() const diff --git a/src/config/tnlConfigEntryList.h b/src/config/tnlConfigEntryList.h index 03f21496c4dada56a0da9cc5089c617398c8ae29..1761effff088b17fce63a0cf119951b17e3bf971 100644 --- a/src/config/tnlConfigEntryList.h +++ b/src/config/tnlConfigEntryList.h @@ -54,7 +54,7 @@ struct tnlConfigEntryList : public tnlConfigEntryBase tnlString getEntryType() const { - return ::getParameterType< tnlList< EntryType > >(); + return ::getType< tnlList< EntryType > >(); } tnlString getUIEntryType() const diff --git a/src/config/tnlParameterContainer.cpp b/src/config/tnlParameterContainer.cpp index 66afa6fd8d0c15f4605fe1c6b769de8f8b7fe4af..b570bf7d67c76cb5b02111accc7021ebad6f6090 100644 --- a/src/config/tnlParameterContainer.cpp +++ b/src/config/tnlParameterContainer.cpp @@ -44,7 +44,7 @@ tnlParameterContainer :: tnlParameterContainer() bool tnlParameterContainer :: AddParameter( const char* name, const char* value ) { - return parameters. Append( new tnlParameter< tnlString >( name, getParameterType< tnlString >().getString(), tnlString( value ) ) ); + return parameters. Append( new tnlParameter< tnlString >( name, ::getType< tnlString >().getString(), tnlString( value ) ) ); } //-------------------------------------------------------------------------- bool tnlParameterContainer :: SetParameter( const char* name, @@ -55,7 +55,7 @@ bool tnlParameterContainer :: SetParameter( const char* name, { if( parameters[ i ] -> name == name ) { - if( parameters[ i ] -> type == getParameterType< tnlString >() ) + if( parameters[ i ] -> type == ::getType< tnlString >() ) { ( ( tnlParameter< tnlString > * ) parameters[ i ] ) -> value. setString( value ); return true; @@ -64,7 +64,7 @@ bool tnlParameterContainer :: SetParameter( const char* name, { cerr << "Parameter " << name << " already exists with different type " << parameters[ i ] -> type << " not " - << getParameterType< tnlString>() << endl; + << ::getType< tnlString>() << endl; abort(); return false; } @@ -177,7 +177,7 @@ bool ParseCommandLine( int argc, char* argv[], const tnlConfigEntryBase* entry; if( ( entry = config_description.getEntry( option ) ) == NULL ) { - cerr << "Unknown parameter " << option << "." << endl; + cerr << "Unknown parameter " << _option << "." << endl; parse_error = true; } else diff --git a/src/config/tnlParameterContainer.h b/src/config/tnlParameterContainer.h index e9872f7b6e60681eaeabc77445bf3cd137138799..2661122832cd4965fa608e797c1decb2b3e2d164 100644 --- a/src/config/tnlParameterContainer.h +++ b/src/config/tnlParameterContainer.h @@ -42,7 +42,7 @@ template< class T > struct tnlParameter : public tnlParameterBase T value; }; -//template< class T > const char* GetParameterType( const T& val ); +//template< class T > const char* getType( const T& val ); class tnlParameterContainer { @@ -120,7 +120,7 @@ bool ParseCommandLine( int argc, char* argv[], template< class T > bool tnlParameterContainer :: AddParameter( const char* name, const T& value ) { - return parameters. Append( new tnlParameter< T >( name, ::getParameterType< T >(). getString(), value ) ); + return parameters. Append( new tnlParameter< T >( name, ::getType< T >(). getString(), value ) ); }; template< class T > bool tnlParameterContainer :: SetParameter( const char* name, @@ -131,7 +131,7 @@ template< class T > bool tnlParameterContainer :: SetParameter( const char* name { if( parameters[ i ] -> name == name ) { - if( parameters[ i ] -> type == GetParameterType( value ) ) + if( parameters[ i ] -> type == getType( value ) ) { ( ( tnlParameter< T > * ) parameters[ i ] ) -> value = value; return true; @@ -140,7 +140,7 @@ template< class T > bool tnlParameterContainer :: SetParameter( const char* name { cerr << "Parameter " << name << " already exists with different type " << parameters[ i ] -> type << " not " - << GetParameterType( value ) << endl; + << getType( value ) << endl; abort( ); return false; } diff --git a/src/core/param-types.h b/src/core/param-types.h index 741d2624c16fbeb2c651818cecb0356b0a57e7ed..5a43683821cf126b941b3a4578b16ad0df6341f5 100644 --- a/src/core/param-types.h +++ b/src/core/param-types.h @@ -22,17 +22,17 @@ #include <core/tnlString.h> template< typename T > -tnlString getParameterType() { return T :: getType(); }; +tnlString getType() { return T :: getType(); }; -template<> inline tnlString getParameterType< bool >() { return tnlString( "bool" ); }; -template<> inline tnlString getParameterType< short int >() { return tnlString( "short int" ); }; -template<> inline tnlString getParameterType< int >() { return tnlString( "int" ); }; -template<> inline tnlString getParameterType< long int >() { return tnlString( "long int" ); }; -template<> inline tnlString getParameterType< char >() { return tnlString( "char" ); }; -template<> inline tnlString getParameterType< float >() { return tnlString( "float" ); }; -template<> inline tnlString getParameterType< double >() { return tnlString( "double" ); }; -template<> inline tnlString getParameterType< long double >() { return tnlString( "long double" ); }; -template<> inline tnlString getParameterType< tnlFloat >() { return tnlString( "tnlFloat" ); }; -template<> inline tnlString getParameterType< tnlDouble> () { return tnlString( "tnlDouble" ); }; +template<> inline tnlString getType< bool >() { return tnlString( "bool" ); }; +template<> inline tnlString getType< short int >() { return tnlString( "short int" ); }; +template<> inline tnlString getType< int >() { return tnlString( "int" ); }; +template<> inline tnlString getType< long int >() { return tnlString( "long int" ); }; +template<> inline tnlString getType< char >() { return tnlString( "char" ); }; +template<> inline tnlString getType< float >() { return tnlString( "float" ); }; +template<> inline tnlString getType< double >() { return tnlString( "double" ); }; +template<> inline tnlString getType< long double >() { return tnlString( "long double" ); }; +template<> inline tnlString getType< tnlFloat >() { return tnlString( "tnlFloat" ); }; +template<> inline tnlString getType< tnlDouble> () { return tnlString( "tnlDouble" ); }; #endif diff --git a/src/core/tnlCurve.h b/src/core/tnlCurve.h index f430c46a5bad82f9c0c0a61eb53bd00335751fc8..89ead3407a12a45bb3846b8bef24520f6af633ae 100644 --- a/src/core/tnlCurve.h +++ b/src/core/tnlCurve.h @@ -92,7 +92,7 @@ template< class T > class tnlCurve : public tnlObject, public tnlList< tnlCurveE tnlString getType() const { - return tnlString( "tnlCurve< " ) + tnlString( getParameterType< T >() ) + tnlString( " >" ); + return tnlString( "tnlCurve< " ) + tnlString( ::getType< T >() ) + tnlString( " >" ); }; //! Append new point diff --git a/src/core/tnlList.h b/src/core/tnlList.h index 456cdc1c042edc43078e26e198093147c29fa5e7..b6ec489c82bc2986d42ae1c607a6d274f693a5b7 100644 --- a/src/core/tnlList.h +++ b/src/core/tnlList.h @@ -92,7 +92,7 @@ template< class T > class tnlList static tnlString getType() { - return tnlString( "tnlList< " ) + ::getParameterType< T >() + tnlString( " >" ); + return tnlString( "tnlList< " ) + ::getType< T >() + tnlString( " >" ); }; //! If the list is empty return 'true' diff --git a/src/core/tnlTimerRT.h b/src/core/tnlTimerRT.h index 3ffee0e33a1952eff264481e7554240fa70901cf..31ab6a4f8003c1dcb7e2d4bb26a0495fc591e8d8 100644 --- a/src/core/tnlTimerRT.h +++ b/src/core/tnlTimerRT.h @@ -43,5 +43,5 @@ class tnlTimerRT bool stop_state; }; -extern tnlTimerRT default_mcore_rt_timer; +extern tnlTimerRT defaultRTTimer; #endif diff --git a/src/functions/tnlConstantFunction.h b/src/functions/tnlConstantFunction.h index 2c6254c5c98377ef744cf71eec2eca677c2729c9..e2a11a9d2b90f3fd7adf60cb436fda25c727dfc9 100644 --- a/src/functions/tnlConstantFunction.h +++ b/src/functions/tnlConstantFunction.h @@ -32,7 +32,11 @@ class tnlConstantFunction tnlConstantFunction(); - bool init( const tnlParameterContainer& parameters ); + static void configSetup( tnlConfigDescription& config, + const tnlString& prefix ); + + bool init( const tnlParameterContainer& parameters, + const tnlString& prefix ); void setValue( const RealType& value ); @@ -41,14 +45,16 @@ class tnlConstantFunction #ifdef HAVE_NOT_CXX11 template< int XDiffOrder, int YDiffOrder, - int ZDiffOrder > - RealType getValue( const VertexType& v ) const; + int ZDiffOrder, + typename Vertex > #else template< int XDiffOrder = 0, int YDiffOrder = 0, - int ZDiffOrder = 0 > - RealType getValue( const VertexType& v ) const; + int ZDiffOrder = 0, + typename Vertex = VertexType > #endif + RealType getValue( const Vertex& v, + const Real& time = 0.0 ) const; protected: diff --git a/src/functions/tnlExpBumpFunction.h b/src/functions/tnlExpBumpFunction.h index 930249b3062e688b7509b455036c06dca9e61311..65eda6762acc67edbd618576189f5a0b38de613b 100644 --- a/src/functions/tnlExpBumpFunction.h +++ b/src/functions/tnlExpBumpFunction.h @@ -28,7 +28,8 @@ class tnlExpBumpFunctionBase typedef Real RealType; - bool init( const tnlParameterContainer& parameters ); + bool init( const tnlParameterContainer& parameters, + const tnlString& prefix ); void setAmplitude( const RealType& amplitude ); @@ -58,20 +59,23 @@ class tnlExpBumpFunction< 1, Real > : public tnlExpBumpFunctionBase< Real > typedef Real RealType; typedef tnlStaticVector< Dimensions, Real > VertexType; + static tnlString getType(); tnlExpBumpFunction(); #ifdef HAVE_NOT_CXX11 template< int XDiffOrder, int YDiffOrder, - int ZDiffOrder > - RealType getF( const VertexType& v ) const; + int ZDiffOrder, + typename Vertex > #else template< int XDiffOrder = 0, int YDiffOrder = 0, - int ZDiffOrder = 0 > - RealType getF( const VertexType& v ) const; + int ZDiffOrder = 0, + typename Vertex = VertexType > #endif + RealType getValue( const Vertex& v, + const Real& time = 0.0 ) const; }; template< typename Real > @@ -83,19 +87,23 @@ class tnlExpBumpFunction< 2, Real > : public tnlExpBumpFunctionBase< Real > typedef Real RealType; typedef tnlStaticVector< Dimensions, Real > VertexType; + static tnlString getType(); + tnlExpBumpFunction(); #ifdef HAVE_NOT_CXX11 template< int XDiffOrder, int YDiffOrder, - int ZDiffOrder > - RealType getF( const VertexType& v ) const; + int ZDiffOrder, + typename Vertex > #else template< int XDiffOrder = 0, int YDiffOrder = 0, - int ZDiffOrder = 0 > - RealType getF( const VertexType& v ) const; + int ZDiffOrder = 0, + typename Vertex = VertexType > #endif + RealType getValue( const Vertex& v, + const Real& time = 0.0 ) const; }; template< typename Real > @@ -107,20 +115,23 @@ class tnlExpBumpFunction< 3, Real > : public tnlExpBumpFunctionBase< Real > typedef Real RealType; typedef tnlStaticVector< Dimensions, Real > VertexType; + static tnlString getType(); tnlExpBumpFunction(); #ifdef HAVE_NOT_CXX11 template< int XDiffOrder, int YDiffOrder, - int ZDiffOrder > - RealType getF( const VertexType& v ) const; + int ZDiffOrder, + typename Vertex > #else template< int XDiffOrder = 0, int YDiffOrder = 0, - int ZDiffOrder = 0 > - RealType getF( const VertexType& v ) const; + int ZDiffOrder = 0, + typename Vertex = VertexType > #endif + RealType getValue( const Vertex& v, + const Real& time = 0.0 ) const; }; #include <implementation/functions/tnlExpBumpFunction_impl.h> diff --git a/src/functions/tnlFunctionDiscretizer.h b/src/functions/tnlFunctionDiscretizer.h index 726e58bd212612099157bfdafa5f13d7b30e7efe..b44addeb7a21a8178e90369cb0e20c3d97db91c0 100644 --- a/src/functions/tnlFunctionDiscretizer.h +++ b/src/functions/tnlFunctionDiscretizer.h @@ -18,25 +18,27 @@ #ifndef TNLFUNCTIONDISCRETIZER_H_ #define TNLFUNCTIONDISCRETIZER_H_ -template< typename Mesh, typename Function, typename DiscreteFunction > +template< typename Mesh, typename Function, typename Vector > class tnlFunctionDiscretizer { public: + typedef typename Vector::DeviceType DeviceType; + #ifdef HAVE_NOT_CXX11 template< int XDiffOrder, int YDiffOrder, int ZDiffOrder > static void discretize( const Mesh& mesh, const Function& function, - DiscreteFunction& discreteFunction ); + Vector& discreteFunction ); #else template< int XDiffOrder = 0, int YDiffOrder = 0, int ZDiffOrder = 0 > static void discretize( const Mesh& mesh, const Function& function, - DiscreteFunction& discreteFunction ); + Vector& discreteFunction ); #endif }; diff --git a/src/functions/tnlSinBumpsFunction.h b/src/functions/tnlSinBumpsFunction.h index 4327965eea203afc50f4614f70fae9057e4bb07e..41ea5c20f06f8dabf7071e4fa35dccb323196ffc 100644 --- a/src/functions/tnlSinBumpsFunction.h +++ b/src/functions/tnlSinBumpsFunction.h @@ -21,113 +21,126 @@ #include <config/tnlParameterContainer.h> #include <core/vectors/tnlStaticVector.h> -template< int Dimensions, typename Vertex = tnlStaticVector< Dimensions, double >, typename Device = tnlHost > +template< typename Vertex > class tnlSinBumpsFunctionBase { public: - typedef Vertex VertexType; - typedef typename VertexType::RealType RealType; + typedef Vertex VertexType; + typedef typename Vertex::RealType RealType; + enum { Dimensions = VertexType::size }; - void setWaveLength( const VertexType& waveLength ); + void setWaveLength( const VertexType& waveLength ); - const VertexType& getWaveLength() const; + const VertexType& getWaveLength() const; - void setAmplitude( const RealType& amplitude ); + void setAmplitude( const RealType& amplitude ); - const RealType& getAmplitude() const; + const RealType& getAmplitude() const; - void setPhase( const VertexType& phase ); + void setPhase( const VertexType& phase ); - const VertexType& getPhase() const; + const VertexType& getPhase() const; protected: - RealType amplitude; + RealType amplitude; - VertexType waveLength, phase; + VertexType waveLength, phase; }; -template< int Dimensions, typename Vertex = tnlStaticVector< Dimensions, double >, typename Device = tnlHost > +template< int Dimensions, typename Real > class tnlSinBumpsFunction { }; -template< typename Vertex, typename Device > -class tnlSinBumpsFunction< 1, Vertex, Device > : public tnlSinBumpsFunctionBase< 1, Vertex, Device > +template< typename Real > +class tnlSinBumpsFunction< 1, Real > : public tnlSinBumpsFunctionBase< tnlStaticVector< 1, Real > > { public: - enum { Dimensions = 1 }; - typedef Vertex VertexType; - typedef typename VertexType::RealType RealType; + enum { Dimensions = 1 }; + typedef tnlSinBumpsFunctionBase< tnlStaticVector< 1, Real > > BaseType; + typedef typename BaseType::VertexType VertexType; + typedef Real RealType; - tnlSinBumpsFunction(); + tnlSinBumpsFunction(); - bool init( const tnlParameterContainer& parameters ); + bool init( const tnlParameterContainer& parameters, + const tnlString& prefix ); #ifdef HAVE_NOT_CXX11 - template< int XDiffOrder, - int YDiffOrder, - int ZDiffOrder > - RealType getF( const VertexType& v ) const; + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > #else - template< int XDiffOrder = 0, - int YDiffOrder = 0, - int ZDiffOrder = 0 > - RealType getF( const VertexType& v ) const; -#endif + template< int XDiffOrder = 0, + int YDiffOrder = 0, + int ZDiffOrder = 0, + typename Vertex = VertexType > +#endif + RealType getValue( const Vertex& v, + const Real& time = 0.0 ) const; }; -template< typename Vertex, typename Device > -class tnlSinBumpsFunction< 2, Vertex, Device > : public tnlSinBumpsFunctionBase< 2, Vertex, Device > +template< typename Real > +class tnlSinBumpsFunction< 2, Real > : public tnlSinBumpsFunctionBase< tnlStaticVector< 2, Real > > { public: - enum { Dimensions = 2 }; - typedef Vertex VertexType; - typedef typename VertexType::RealType RealType; + enum { Dimensions = 2 }; + typedef tnlSinBumpsFunctionBase< tnlStaticVector< 2, Real > > BaseType; + typedef typename BaseType::VertexType VertexType; + typedef Real RealType; - tnlSinBumpsFunction(); + tnlSinBumpsFunction(); - bool init( const tnlParameterContainer& parameters ); + bool init( const tnlParameterContainer& parameters, + const tnlString& prefix ); #ifdef HAVE_NOT_CXX11 - template< int XDiffOrder, - int YDiffOrder, - int ZDiffOrder > - RealType getF( const VertexType& v ) const; + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > #else - template< int XDiffOrder = 0, - int YDiffOrder = 0, - int ZDiffOrder = 0 > - RealType getF( const VertexType& v ) const; -#endif + template< int XDiffOrder = 0, + int YDiffOrder = 0, + int ZDiffOrder = 0, + typename Vertex = VertexType > +#endif + RealType getValue( const Vertex& v, + const Real& time = 0.0 ) const; }; -template< typename Vertex, typename Device > -class tnlSinBumpsFunction< 3, Vertex, Device > : public tnlSinBumpsFunctionBase< 3, Vertex, Device > +template< typename Real > +class tnlSinBumpsFunction< 3, Real > : public tnlSinBumpsFunctionBase< tnlStaticVector< 3, Real > > { public: - enum { Dimensions = 3 }; - typedef Vertex VertexType; - typedef typename VertexType::RealType RealType; + enum { Dimensions = 3 }; + typedef tnlSinBumpsFunctionBase< tnlStaticVector< 3, Real > > BaseType; + typedef typename BaseType::VertexType VertexType; + typedef Real RealType; - tnlSinBumpsFunction(); + tnlSinBumpsFunction(); - bool init( const tnlParameterContainer& parameters ); + bool init( const tnlParameterContainer& parameters, + const tnlString& prefix ); #ifdef HAVE_NOT_CXX11 - template< int XDiffOrder, - int YDiffOrder, - int ZDiffOrder > - RealType getF( const VertexType& v ) const; + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > #else - template< int XDiffOrder = 0, - int YDiffOrder = 0, - int ZDiffOrder = 0 > - RealType getF( const VertexType& v ) const; + template< int XDiffOrder = 0, + int YDiffOrder = 0, + int ZDiffOrder = 0, + typename Vertex = VertexType > + RealType getValue( const Vertex& v, + const Real& time = 0.0 ) const; #endif }; diff --git a/src/functions/tnlSinWaveFunction.h b/src/functions/tnlSinWaveFunction.h index a3819e870fd86510f0c869ee9dbd6392cf5a043f..9e28318c1a295da16e2c77d9a37933470435096f 100644 --- a/src/functions/tnlSinWaveFunction.h +++ b/src/functions/tnlSinWaveFunction.h @@ -28,7 +28,8 @@ class tnlSinWaveFunctionBase tnlSinWaveFunctionBase(); - bool init( const tnlParameterContainer& parameters ); + bool init( const tnlParameterContainer& parameters, + const tnlString& prefix ); void setWaveLength( const Real& waveLength ); @@ -47,76 +48,83 @@ class tnlSinWaveFunctionBase Real waveLength, amplitude, phase, wavesNumber; }; -template< int Dimensions, typename Vertex = tnlStaticVector< Dimensions, double >, typename Device = tnlHost > +template< int Dimensions, typename Real > class tnlSinWaveFunction { }; -template< typename Vertex, typename Device > -class tnlSinWaveFunction< 1, Vertex, Device > : public tnlSinWaveFunctionBase< typename Vertex::RealType > +template< typename Real > +class tnlSinWaveFunction< 1, Real > : public tnlSinWaveFunctionBase< Real > { public: - enum { Dimensions = 1 }; - typedef Vertex VertexType; - typedef typename VertexType::RealType RealType; + enum { Dimensions = 1 }; + typedef tnlStaticVector< 1, Real > VertexType; + typedef Real RealType; #ifdef HAVE_NOT_CXX11 - template< int XDiffOrder, - int YDiffOrder, - int ZDiffOrder > - RealType getF( const VertexType& v ) const; + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > #else - template< int XDiffOrder = 0, - int YDiffOrder = 0, - int ZDiffOrder = 0 > - RealType getF( const VertexType& v ) const; + template< int XDiffOrder = 0, + int YDiffOrder = 0, + int ZDiffOrder = 0, + typename Vertex = VertexType > #endif + RealType getValue( const Vertex& v, + const Real& time = 0.0 ) const; }; -template< typename Vertex, typename Device > -class tnlSinWaveFunction< 2, Vertex, Device > : public tnlSinWaveFunctionBase< typename Vertex::RealType > +template< typename Real > +class tnlSinWaveFunction< 2, Real > : public tnlSinWaveFunctionBase< Real > { public: - enum { Dimensions = 2 }; - typedef Vertex VertexType; - typedef typename VertexType::RealType RealType; + enum { Dimensions = 2 }; + typedef tnlStaticVector< 2, Real > VertexType; + typedef Real RealType; #ifdef HAVE_NOT_CXX11 - template< int XDiffOrder, - int YDiffOrder, - int ZDiffOrder > - RealType getF( const VertexType& v ) const; + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > #else - template< int XDiffOrder = 0, - int YDiffOrder = 0, - int ZDiffOrder = 0 > - RealType getF( const VertexType& v ) const; + template< int XDiffOrder = 0, + int YDiffOrder = 0, + int ZDiffOrder = 0, + typename Vertex = VertexType > #endif + RealType getValue( const Vertex& v, + const Real& time = 0.0 ) const; }; -template< typename Vertex, typename Device > -class tnlSinWaveFunction< 3, Vertex, Device > : public tnlSinWaveFunctionBase< typename Vertex::RealType > +template< typename Real > +class tnlSinWaveFunction< 3, Real > : public tnlSinWaveFunctionBase< Real > { public: - enum { Dimensions = 3 }; - typedef Vertex VertexType; - typedef typename VertexType::RealType RealType; + enum { Dimensions = 3 }; + typedef tnlStaticVector< 3, Real > VertexType; + typedef Real RealType; + #ifdef HAVE_NOT_CXX11 - template< int XDiffOrder, - int YDiffOrder, - int ZDiffOrder > - RealType getF( const VertexType& v ) const; + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > #else - template< int XDiffOrder = 0, - int YDiffOrder = 0, - int ZDiffOrder = 0 > - RealType getF( const VertexType& v ) const; + template< int XDiffOrder = 0, + int YDiffOrder = 0, + int ZDiffOrder = 0, + typename Vertex = VertexType > #endif + RealType getValue( const Vertex& v, + const Real& time = 0.0 ) const; }; #include <implementation/functions/tnlSinWaveFunction_impl.h> diff --git a/src/functions/tnlTestFunction.h b/src/functions/tnlTestFunction.h index 9a425ae89711b73e0becf9861d1b5d9739dfcbd0..1aca9bd64d92a27d1c5ca28ba06cc5f8e04ce53c 100644 --- a/src/functions/tnlTestFunction.h +++ b/src/functions/tnlTestFunction.h @@ -18,20 +18,25 @@ #ifndef TNLTESTFUNCTION_H_ #define TNLTESTFUNCTION_H_ +#include <core/tnlHost.h> template< int FunctionDimensions, typename Real, - typename Device > + typename Device = tnlHost > class tnlTestFunction { protected: - enum TestFunctions{ none, - constant, + enum TestFunctions{ constant, expBump, sinBumps, sinWave }; + enum TimeDependence { none, + linear, + quadratic, + sine }; + public: enum{ Dimensions = FunctionDimensions }; @@ -40,20 +45,53 @@ class tnlTestFunction tnlTestFunction(); - bool init( const tnlParameterContainer& parameters ); - - template< typename Vertex > + static void configSetup( tnlConfigDescription& config, + const tnlString& prefix = "" ); + + bool init( const tnlParameterContainer& parameters, + const tnlString& prefix = "" ); + +#ifdef HAVE_NOT_CXX11 + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > +#else + template< int XDiffOrder = 0, + int YDiffOrder = 0, + int ZDiffOrder = 0, + typename Vertex = VertexType > +#endif #ifdef HAVE_CUDA __device__ __host__ #endif - Real getValue( const Vertex& vertex ) const; + Real getValue( const Vertex& vertex, + const Real& time ) const; + +#ifdef HAVE_NOT_CXX11 + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > +#else + template< int XDiffOrder = 0, + int YDiffOrder = 0, + int ZDiffOrder = 0, + typename Vertex = VertexType > +#endif +#ifdef HAVE_CUDA + __device__ __host__ +#endif + Real getTimeDerivative( const Vertex& vertex, + const Real& time ) const; ~tnlTestFunction(); protected: template< typename FunctionType > - bool initFunction( const tnlParameterContainer& parameters ); + bool initFunction( const tnlParameterContainer& parameters, + const tnlString& prefix = "" ); template< typename FunctionType > void deleteFunction(); @@ -62,6 +100,10 @@ class tnlTestFunction TestFunctions functionType; + TimeDependence timeDependence; + + Real timeScale; + }; #include <implementation/functions/tnlTestFunction_impl.h> diff --git a/src/implementation/CMakeLists.txt b/src/implementation/CMakeLists.txt index 527fa21d73564f314b96ca971fb596bdce85f49d..fcfa595dcf606cf127179db6673f087803179a8a 100755 --- a/src/implementation/CMakeLists.txt +++ b/src/implementation/CMakeLists.txt @@ -3,7 +3,7 @@ ADD_SUBDIRECTORY( core ) ADD_SUBDIRECTORY( matrices ) ADD_SUBDIRECTORY( mesh ) ADD_SUBDIRECTORY( functions ) -ADD_SUBDIRECTORY( schemes ) +ADD_SUBDIRECTORY( operators ) ADD_SUBDIRECTORY( solvers ) SET( headers ) @@ -14,7 +14,7 @@ IF( BUILD_CUDA ) ${tnl_implementation_matrices_CUDA__SOURCES} ${tnl_implementation_mesh_CUDA__SOURCES} ${tnl_implementation_generators_CUDA__SOURCES} - ${tnl_implementation_schemes_CUDA__SOURCES} + ${tnl_implementation_operators_CUDA__SOURCES} ${tnl_implementation_solvers_CUDA__SOURCES} PARENT_SCOPE ) ENDIF() @@ -25,7 +25,7 @@ set( tnl_implementation_SOURCES ${tnl_implementation_generators_SOURCES} ${tnl_implementation_matrices_SOURCES} ${tnl_implementation_mesh_SOURCES} - ${tnl_implementation_schemes_SOURCES} + ${tnl_implementation_operators_SOURCES} ${tnl_implementation_solvers_SOURCES} PARENT_SCOPE ) diff --git a/src/implementation/core/arrays/tnlArray_impl.h b/src/implementation/core/arrays/tnlArray_impl.h index 98189e135d37f415c594295dca7fda1431f6cdc9..c03ed290d6619c0d1390559bf45ae24b243380b4 100644 --- a/src/implementation/core/arrays/tnlArray_impl.h +++ b/src/implementation/core/arrays/tnlArray_impl.h @@ -51,9 +51,9 @@ template< typename Element, tnlString tnlArray< Element, Device, Index > :: getType() { return tnlString( "tnlArray< " ) + - getParameterType< Element >() + ", " + + ::getType< Element >() + ", " + Device :: getDeviceType() + ", " + - getParameterType< Index >() + + ::getType< Index >() + " >"; }; diff --git a/src/implementation/core/arrays/tnlConstSharedArray_impl.h b/src/implementation/core/arrays/tnlConstSharedArray_impl.h index 9038f9f44ad6ea3f22d0aa32a8d30bd4c65df73f..66c4cde10e54260e46ebb218539aa2ad0989d416 100644 --- a/src/implementation/core/arrays/tnlConstSharedArray_impl.h +++ b/src/implementation/core/arrays/tnlConstSharedArray_impl.h @@ -41,9 +41,9 @@ template< typename Element, tnlString tnlConstSharedArray< Element, Device, Index > :: getType() const { return tnlString( "tnlConstSharedArray< " ) + ", " + - getParameterType< Element >() + ", " + + ::getType< Element >() + ", " + Device::getDeviceType() + ", " + - getParameterType< Index >() + " >"; + ::getType< Index >() + " >"; }; template< typename Element, diff --git a/src/implementation/core/arrays/tnlMultiArray1D_impl.h b/src/implementation/core/arrays/tnlMultiArray1D_impl.h index c1984a57c8e990fc251ac667ce2d4462a14de17f..fe408d60e711c5493f36f318edc4554c28300217 100644 --- a/src/implementation/core/arrays/tnlMultiArray1D_impl.h +++ b/src/implementation/core/arrays/tnlMultiArray1D_impl.h @@ -38,11 +38,11 @@ tnlString tnlMultiArray< 1, Element, Device, Index > :: getType() const return tnlString( "tnlMultiArray< ") + tnlString( Dimensions ) + tnlString( ", " ) + - tnlString( getParameterType< Element >() ) + + tnlString( ::getType< Element >() ) + tnlString( ", " ) + tnlString( Device :: getDeviceType() ) + tnlString( ", " ) + - tnlString( getParameterType< Index >() ) + + tnlString( ::getType< Index >() ) + tnlString( " >" ); } diff --git a/src/implementation/core/arrays/tnlMultiArray2D_impl.h b/src/implementation/core/arrays/tnlMultiArray2D_impl.h index 2435a4f5596841e2841e4bfaf349c7879344836d..62781a9fa9bc68f7b4074b764d7570066c59fd41 100644 --- a/src/implementation/core/arrays/tnlMultiArray2D_impl.h +++ b/src/implementation/core/arrays/tnlMultiArray2D_impl.h @@ -41,11 +41,11 @@ tnlString tnlMultiArray< 2, Element, Device, Index > :: getType() const return tnlString( "tnlMultiArray< ") + tnlString( Dimensions ) + tnlString( ", " ) + - tnlString( getParameterType< Element >() ) + + tnlString( ::getType< Element >() ) + tnlString( ", " ) + tnlString( Device :: getDeviceType() ) + tnlString( ", " ) + - tnlString( getParameterType< Index >() ) + + tnlString( ::getType< Index >() ) + tnlString( " >" ); } diff --git a/src/implementation/core/arrays/tnlMultiArray3D_impl.h b/src/implementation/core/arrays/tnlMultiArray3D_impl.h index 095dd20896d9817c77d0e455ecddb81d2778fb72..c03cab7d58532fcc97fa83c0f5a4ef1a27c5c004 100644 --- a/src/implementation/core/arrays/tnlMultiArray3D_impl.h +++ b/src/implementation/core/arrays/tnlMultiArray3D_impl.h @@ -40,11 +40,11 @@ tnlString tnlMultiArray< 3, Element, Device, Index > :: getType() const return tnlString( "tnlMultiArray< ") + tnlString( Dimensions ) + tnlString( ", " ) + - tnlString( getParameterType< Element >() ) + + tnlString( ::getType< Element >() ) + tnlString( ", " ) + tnlString( Device :: getDeviceType() ) + tnlString( ", " ) + - tnlString( getParameterType< Index >() ) + + tnlString( ::getType< Index >() ) + tnlString( " >" ); } diff --git a/src/implementation/core/arrays/tnlMultiArray4D_impl.h b/src/implementation/core/arrays/tnlMultiArray4D_impl.h index a0fb0684ebf8e60604476fd05861b77812b27925..75fb67b26dce18ce2eddfbacda882b8acc8b105a 100644 --- a/src/implementation/core/arrays/tnlMultiArray4D_impl.h +++ b/src/implementation/core/arrays/tnlMultiArray4D_impl.h @@ -40,11 +40,11 @@ tnlString tnlMultiArray< 4, Element, Device, Index > :: getType() const return tnlString( "tnlMultiArray< ") + tnlString( Dimensions ) + tnlString( ", " ) + - tnlString( getParameterType< Element >() ) + + tnlString( ::getType< Element >() ) + tnlString( ", " ) + tnlString( Device :: getDeviceType() ) + tnlString( ", " ) + - tnlString( getParameterType< Index >() ) + + tnlString( ::getType< Index >() ) + tnlString( " >" ); } diff --git a/src/implementation/core/arrays/tnlSharedArray_impl.h b/src/implementation/core/arrays/tnlSharedArray_impl.h index 61969a81b0f037de8e8300ab6029c327a6cb3ad3..60e04877effca42d64c068f67245a87c6d38c575 100644 --- a/src/implementation/core/arrays/tnlSharedArray_impl.h +++ b/src/implementation/core/arrays/tnlSharedArray_impl.h @@ -67,9 +67,9 @@ template< typename Element, tnlString tnlSharedArray< Element, Device, Index > :: getType() const { return tnlString( "tnlSharedArray< " ) + ", " + - getParameterType< Element >() + ", " + + ::getType< Element >() + ", " + Device::getDeviceType() + ", " + - getParameterType< Index >() + " >"; + ::getType< Index >() + " >"; }; template< typename Element, diff --git a/src/implementation/core/arrays/tnlStaticArray1D_impl.h b/src/implementation/core/arrays/tnlStaticArray1D_impl.h index c79158092526fbe4586bf0e2556ae4cc908e2549..501787c2237ca60af6a2f36c91ec71529d668d22 100644 --- a/src/implementation/core/arrays/tnlStaticArray1D_impl.h +++ b/src/implementation/core/arrays/tnlStaticArray1D_impl.h @@ -61,7 +61,7 @@ tnlString tnlStaticArray< 1, Element >::getType() return tnlString( "tnlStaticArray< " ) + tnlString( size ) + tnlString( ", " ) + - getParameterType< Element >() + + ::getType< Element >() + tnlString( " >" ); } diff --git a/src/implementation/core/arrays/tnlStaticArray2D_impl.h b/src/implementation/core/arrays/tnlStaticArray2D_impl.h index 93b3a836a37fdd2dbe037565907018323637204c..2f8b8d317f8e3af5a29133dab2edd56edabc7687 100644 --- a/src/implementation/core/arrays/tnlStaticArray2D_impl.h +++ b/src/implementation/core/arrays/tnlStaticArray2D_impl.h @@ -74,7 +74,7 @@ tnlString tnlStaticArray< 2, Element >::getType() return tnlString( "tnlStaticArray< " ) + tnlString( size ) + tnlString( ", " ) + - getParameterType< Element >() + + ::getType< Element >() + tnlString( " >" ); } diff --git a/src/implementation/core/arrays/tnlStaticArray3D_impl.h b/src/implementation/core/arrays/tnlStaticArray3D_impl.h index a5b41f0c096322d70f4ecbf1d4590c3cd11448d0..8f5399d1ab0c3347e8671c17e92bbce19ee5d791 100644 --- a/src/implementation/core/arrays/tnlStaticArray3D_impl.h +++ b/src/implementation/core/arrays/tnlStaticArray3D_impl.h @@ -78,7 +78,7 @@ tnlString tnlStaticArray< 3, Element >::getType() return tnlString( "tnlStaticArray< " ) + tnlString( size ) + tnlString( ", " ) + - getParameterType< Element >() + + ::getType< Element >() + tnlString( " >" ); } diff --git a/src/implementation/core/arrays/tnlStaticArray_impl.h b/src/implementation/core/arrays/tnlStaticArray_impl.h index 3647993a1d6b1e67212f0d39d2f45ce8fbaea638..43e4c049822ba441d4f7b12de8fa29a1e43a4efe 100644 --- a/src/implementation/core/arrays/tnlStaticArray_impl.h +++ b/src/implementation/core/arrays/tnlStaticArray_impl.h @@ -64,7 +64,7 @@ tnlString tnlStaticArray< Size, Element >::getType() return tnlString( "tnlStaticArray< " ) + tnlString( Size ) + tnlString( ", " ) + - getParameterType< Element >() + + ::getType< Element >() + tnlString( " >" ); } diff --git a/src/implementation/core/containers/tnlContainer_impl.h b/src/implementation/core/containers/tnlContainer_impl.h index 7d4b9d0955df8e2f96b30268b0e6378be8c226ca..7f8a88fb1f7f0dd5cc657058d3036ff7558e204c 100644 --- a/src/implementation/core/containers/tnlContainer_impl.h +++ b/src/implementation/core/containers/tnlContainer_impl.h @@ -33,9 +33,9 @@ template< typename Element, typename Device, typename Index > tnlString tnlContainer< Element, Device, Index >::getType() { return tnlString( "tnlContainer< " ) + - getParameterType< Element >() + + ::getType< Element >() + Device :: getDeviceType() + - getParameterType< Index >() + + ::getType< Index >() + " >"; } diff --git a/src/implementation/core/containers/tnlStaticContainer_impl.h b/src/implementation/core/containers/tnlStaticContainer_impl.h index 632fa7b80c3f471cc0bc5522fa04d3e12c0bee88..2603bf65c250bbb4a8cc7fe371eb225dba23a950 100644 --- a/src/implementation/core/containers/tnlStaticContainer_impl.h +++ b/src/implementation/core/containers/tnlStaticContainer_impl.h @@ -29,7 +29,7 @@ tnlString tnlStaticContainer< Size, Element >::getType() return tnlString( "tnlStaticContainer< " ) + tnlString( Size ) + tnlString( ", " ) + - getParameterType< Element >() + + ::getType< Element >() + tnlString( " >" ); } diff --git a/src/implementation/core/tnlCuda_impl.h b/src/implementation/core/tnlCuda_impl.h index bbbaadf5237cfed7a13d4c3ef81b0ec2070cb6f8..253937fb2fac0c707b6a706771fc5783e817289c 100644 --- a/src/implementation/core/tnlCuda_impl.h +++ b/src/implementation/core/tnlCuda_impl.h @@ -130,8 +130,12 @@ void tnlCuda::passFromDevice( const ObjectType& deviceObject, template< typename ObjectType > void tnlCuda::freeFromDevice( ObjectType* deviceObject ) { +#ifdef HAVE_CUDA cudaFree( deviceObject ); checkCudaDevice; +#else + tnlAssert( false, cerr << "CUDA support is missing." ); +#endif } #ifdef HAVE_CUDA diff --git a/src/implementation/core/tnlString.cpp b/src/implementation/core/tnlString.cpp index dcf39281e93431458a40bebae3c684f23033e9cc..cabbc8840f861e6d4d231d3cee1716e7594a95e5 100644 --- a/src/implementation/core/tnlString.cpp +++ b/src/implementation/core/tnlString.cpp @@ -207,34 +207,34 @@ bool tnlString :: operator == ( const char* str ) const if( strcmp( string, str ) == 0 ) return true; return false; } -//--------------------------------------------------------------------------- + tnlString :: operator bool () const { if( string[ 0 ] ) return true; return false; } -//--------------------------------------------------------------------------- + bool tnlString :: operator != ( const char* str ) const { return ! operator == ( str ); } -//--------------------------------------------------------------------------- + int tnlString :: getLength() const { return strlen( string ); } -//--------------------------------------------------------------------------- + const char* tnlString :: getString() const { return string; } -//--------------------------------------------------------------------------- + char* tnlString :: getString() { return string; } -//--------------------------------------------------------------------------- + bool tnlString :: save( ostream& file ) const { dbgFunctionName( "tnlString", "save" ); @@ -247,7 +247,7 @@ bool tnlString :: save( ostream& file ) const if( file. bad() ) return false; return true; } -//--------------------------------------------------------------------------- + bool tnlString :: load( istream& file ) { int _length; @@ -276,7 +276,7 @@ bool tnlString :: load( istream& file ) string[ _length ] = 0; return true; } -//--------------------------------------------------------------------------- + bool tnlString :: save( tnlFile& file ) const { dbgFunctionName( "tnlString", "Write" ); @@ -299,7 +299,7 @@ bool tnlString :: save( tnlFile& file ) const return false; return true; } -//--------------------------------------------------------------------------- + bool tnlString :: load( tnlFile& file ) { int _length; @@ -342,7 +342,7 @@ bool tnlString :: load( tnlFile& file ) string[ _length ] = 0; return true; } -//--------------------------------------------------------------------------- + void tnlString :: MPIBcast( int root, MPI_Comm comm ) { #ifdef HAVE_MPI @@ -369,7 +369,7 @@ void tnlString :: MPIBcast( int root, MPI_Comm comm ) dbgExpr( string ); #endif } -//--------------------------------------------------------------------------- + bool tnlString :: getLine( istream& stream ) { std :: string str; @@ -378,7 +378,7 @@ bool tnlString :: getLine( istream& stream ) if( ! ( *this ) ) return false; return true; } -//--------------------------------------------------------------------------- + int tnlString :: parse( tnlList< tnlString >& list, const char separator ) const { dbgFunctionName( "tnlString", "parse" ); @@ -399,7 +399,7 @@ int tnlString :: parse( tnlList< tnlString >& list, const char separator ) const } return list. getSize(); } -//--------------------------------------------------------------------------- + ostream& operator << ( ostream& stream, const tnlString& str ) { stream << str. getString(); diff --git a/src/implementation/core/tnlTimerRT.cpp b/src/implementation/core/tnlTimerRT.cpp index c8d9bb9aad040c0be0ae833e625b182401f964b8..8d2fa297e056a4f216ad0b344e2e8a77ce6e4360 100644 --- a/src/implementation/core/tnlTimerRT.cpp +++ b/src/implementation/core/tnlTimerRT.cpp @@ -25,13 +25,13 @@ #endif -tnlTimerRT default_mcore_rt_timer; -//-------------------------------------------------------------------------- +tnlTimerRT defaultRTTimer; + tnlTimerRT :: tnlTimerRT() { Reset(); } -//-------------------------------------------------------------------------- + void tnlTimerRT :: Reset() { #ifdef HAVE_TIME @@ -45,7 +45,7 @@ void tnlTimerRT :: Reset() #endif } -//-------------------------------------------------------------------------- + void tnlTimerRT :: Stop() { #ifdef HAVE_TIME @@ -58,7 +58,7 @@ void tnlTimerRT :: Stop() } #endif } -//-------------------------------------------------------------------------- + void tnlTimerRT :: Continue() { #ifdef HAVE_TIME @@ -68,7 +68,7 @@ void tnlTimerRT :: Continue() stop_state = false; #endif } -//-------------------------------------------------------------------------- + double tnlTimerRT :: GetTime() { #ifdef HAVE_TIME diff --git a/src/implementation/core/vectors/tnlMultiVector1D_impl.h b/src/implementation/core/vectors/tnlMultiVector1D_impl.h index d386db882999c3acdcdd79450cf691e31546a12d..6046ffadce2d75f0e55a64c7ade045bae299a167 100644 --- a/src/implementation/core/vectors/tnlMultiVector1D_impl.h +++ b/src/implementation/core/vectors/tnlMultiVector1D_impl.h @@ -37,11 +37,11 @@ tnlString tnlMultiVector< 1, Element, Device, Index > :: getType() const return tnlString( "tnlMultiVector< ") + tnlString( Dimensions ) + tnlString( ", " ) + - tnlString( getParameterType< Element >() ) + + tnlString( ::getType< Element >() ) + tnlString( ", " ) + tnlString( Device :: getDeviceType() ) + tnlString( ", " ) + - tnlString( getParameterType< Index >() ) + + tnlString( ::getType< Index >() ) + tnlString( " >" ); } diff --git a/src/implementation/core/vectors/tnlMultiVector2D_impl.h b/src/implementation/core/vectors/tnlMultiVector2D_impl.h index 0c325a7b2326271f303bd1e05e0ca50c9bbae823..2896a914d8d645c6514c9780c4b9e38ad6c6aa1f 100644 --- a/src/implementation/core/vectors/tnlMultiVector2D_impl.h +++ b/src/implementation/core/vectors/tnlMultiVector2D_impl.h @@ -38,11 +38,11 @@ tnlString tnlMultiVector< 2, Element, Device, Index > :: getType() const return tnlString( "tnlMultiVector< ") + tnlString( Dimensions ) + tnlString( ", " ) + - tnlString( getParameterType< Element >() ) + + tnlString( ::getType< Element >() ) + tnlString( ", " ) + tnlString( Device :: getDeviceType() ) + tnlString( ", " ) + - tnlString( getParameterType< Index >() ) + + tnlString( ::getType< Index >() ) + tnlString( " >" ); } diff --git a/src/implementation/core/vectors/tnlMultiVector3D_impl.h b/src/implementation/core/vectors/tnlMultiVector3D_impl.h index 0866d4cb8d4fa938a25592aadaabfc20d312afff..96320e8d34418ce3aede7fc0d7892a67867f2152 100644 --- a/src/implementation/core/vectors/tnlMultiVector3D_impl.h +++ b/src/implementation/core/vectors/tnlMultiVector3D_impl.h @@ -37,11 +37,11 @@ tnlString tnlMultiVector< 3, Element, Device, Index > :: getType() const return tnlString( "tnlMultiVector< ") + tnlString( Dimensions ) + tnlString( ", " ) + - tnlString( getParameterType< Element >() ) + + tnlString( ::getType< Element >() ) + tnlString( ", " ) + tnlString( Device :: getDeviceType() ) + tnlString( ", " ) + - tnlString( getParameterType< Index >() ) + + tnlString( ::getType< Index >() ) + tnlString( " >" ); } diff --git a/src/implementation/core/vectors/tnlMultiVector4D_impl.h b/src/implementation/core/vectors/tnlMultiVector4D_impl.h index 2b63cc857c0e42a1c2a24e2dbd785ce4223eda81..ff4f47135a774785e5d3edd861c070485ac51770 100644 --- a/src/implementation/core/vectors/tnlMultiVector4D_impl.h +++ b/src/implementation/core/vectors/tnlMultiVector4D_impl.h @@ -37,11 +37,11 @@ tnlString tnlMultiVector< 4, Element, Device, Index > :: getType() const return tnlString( "tnlMultiVector< ") + tnlString( Dimensions ) + tnlString( ", " ) + - tnlString( getParameterType< Element >() ) + + tnlString( ::getType< Element >() ) + tnlString( ", " ) + tnlString( Device :: getDeviceType() ) + tnlString( ", " ) + - tnlString( getParameterType< Index >() ) + + tnlString( ::getType< Index >() ) + tnlString( " >" ); } diff --git a/src/implementation/core/vectors/tnlSharedVector_impl.h b/src/implementation/core/vectors/tnlSharedVector_impl.h index 3a392ff39f68b16849e4362001b0e47323e2f258..2b050da513feec5076185b20c104f9f99cf3cdd1 100644 --- a/src/implementation/core/vectors/tnlSharedVector_impl.h +++ b/src/implementation/core/vectors/tnlSharedVector_impl.h @@ -58,9 +58,9 @@ template< typename Real, tnlString tnlSharedVector< Real, Device, Index > :: getType() const { return tnlString( "tnlVector< " ) + - getParameterType< Real >() + ", " + + ::getType< Real >() + ", " + Device :: getDeviceType() + ", " + - getParameterType< Index >() + " >"; + ::getType< Index >() + " >"; /**** * It seems that there is no reason to differ here between vector and shared vector. * This method is used mainly (or only) for loading and saving of objects. diff --git a/src/implementation/core/vectors/tnlStaticVector1D_impl.h b/src/implementation/core/vectors/tnlStaticVector1D_impl.h index 3632cbf7971f72adb31583937984246175e195b8..1d507a6c5dbc08397c0277cc5a197d2faaed6a93 100644 --- a/src/implementation/core/vectors/tnlStaticVector1D_impl.h +++ b/src/implementation/core/vectors/tnlStaticVector1D_impl.h @@ -50,7 +50,7 @@ tnlString tnlStaticVector< 1, Real >::getType() return tnlString( "tnlStaticVector< " ) + tnlString( 1 ) + tnlString( ", " ) + - getParameterType< Real >() + + ::getType< Real >() + tnlString( " >" ); } diff --git a/src/implementation/core/vectors/tnlStaticVector2D_impl.h b/src/implementation/core/vectors/tnlStaticVector2D_impl.h index 9d20d0957b8a583f237f917443e724acade8c463..dce884747ffab2b0ae9d9e3b0032fcbf92a2bb36 100644 --- a/src/implementation/core/vectors/tnlStaticVector2D_impl.h +++ b/src/implementation/core/vectors/tnlStaticVector2D_impl.h @@ -68,7 +68,7 @@ tnlString tnlStaticVector< 2, Real >::getType() return tnlString( "tnlStaticVector< " ) + tnlString( 2 ) + tnlString( ", " ) + - getParameterType< Real >() + + ::getType< Real >() + tnlString( " >" ); } diff --git a/src/implementation/core/vectors/tnlStaticVector3D_impl.h b/src/implementation/core/vectors/tnlStaticVector3D_impl.h index 2d0c900d7b2e7dbcf95b049f1794463222795de1..bed2ed818f8417489647d5890f855761e50f58bd 100644 --- a/src/implementation/core/vectors/tnlStaticVector3D_impl.h +++ b/src/implementation/core/vectors/tnlStaticVector3D_impl.h @@ -68,7 +68,7 @@ tnlString tnlStaticVector< 3, Real >::getType() return tnlString( "tnlStaticVector< " ) + tnlString( 3 ) + tnlString( ", " ) + - getParameterType< Real >() + + ::getType< Real >() + tnlString( " >" ); } diff --git a/src/implementation/core/vectors/tnlStaticVector_impl.h b/src/implementation/core/vectors/tnlStaticVector_impl.h index 49774a2fb030bf6e84072d877f4bbb7d2145b57d..7a041e215cd5c88a65a019e043c26d92599e9d1d 100644 --- a/src/implementation/core/vectors/tnlStaticVector_impl.h +++ b/src/implementation/core/vectors/tnlStaticVector_impl.h @@ -59,7 +59,7 @@ tnlString tnlStaticVector< Size, Real >::getType() return tnlString( "tnlStaticVector< " ) + tnlString( Size ) + tnlString( ", " ) + - getParameterType< Real >() + + ::getType< Real >() + tnlString( " >" ); } diff --git a/src/implementation/core/vectors/tnlVector_impl.h b/src/implementation/core/vectors/tnlVector_impl.h index cc3f09fd10e8a19d716b0191a3b9dfb57ad9acba..beab0badbc65851b51f4981dfb7f2d3b65a13750 100644 --- a/src/implementation/core/vectors/tnlVector_impl.h +++ b/src/implementation/core/vectors/tnlVector_impl.h @@ -52,9 +52,9 @@ template< typename Real, tnlString tnlVector< Real, Device, Index > :: getType() { return tnlString( "tnlVector< " ) + - getParameterType< Real >() + ", " + + ::getType< Real >() + ", " + Device :: getDeviceType() + ", " + - getParameterType< Index >() + " >"; + ::getType< Index >() + " >"; }; template< typename Real, diff --git a/src/implementation/functions/tnlConstantFunction_impl.h b/src/implementation/functions/tnlConstantFunction_impl.h index d32deeba291a033eaab34c81442a31e4d7046d7d..a7806f23a1b352c5216634746515b9085df1fb87 100644 --- a/src/implementation/functions/tnlConstantFunction_impl.h +++ b/src/implementation/functions/tnlConstantFunction_impl.h @@ -48,20 +48,26 @@ template< int Dimensions, typename Real > bool tnlConstantFunction< Dimensions, Real >:: -init( const tnlParameterContainer& parameters ) +init( const tnlParameterContainer& parameters, + const tnlString& prefix ) { - + this->setValue( parameters.GetParameter< double >( prefix + "-value") ); + return true; } template< int Dimensions, typename Real > template< int XDiffOrder, int YDiffOrder, - int ZDiffOrder > + int ZDiffOrder, + typename Vertex > Real tnlConstantFunction< Dimensions, Real >:: -getValue( const VertexType& v ) const +getValue( const Vertex& v, + const Real& time ) const { + if( XDiffOrder || YDiffOrder || ZDiffOrder ) + return 0.0; return value; } diff --git a/src/implementation/functions/tnlExpBumpFunction_impl.h b/src/implementation/functions/tnlExpBumpFunction_impl.h index 753762d0b8e9d197c96c4c1d10f7309a5f75d4e9..be004a17dc0208e7ef0c075dc0e15b1f9a698fae 100644 --- a/src/implementation/functions/tnlExpBumpFunction_impl.h +++ b/src/implementation/functions/tnlExpBumpFunction_impl.h @@ -21,10 +21,13 @@ #include <functions/tnlExpBumpFunction.h> template< typename Real > -bool tnlExpBumpFunctionBase< Real >::init( const tnlParameterContainer& parameters ) +bool +tnlExpBumpFunctionBase< Real >:: +init( const tnlParameterContainer& parameters, + const tnlString& prefix ) { - this->amplitude = parameters.GetParameter< double >( "amplitude" ); - this->sigma = parameters.GetParameter< double >( "sigma" ); + this->amplitude = parameters.GetParameter< double >( prefix + "amplitude" ); + this->sigma = parameters.GetParameter< double >( prefix + "sigma" ); return true; } @@ -56,14 +59,26 @@ const Real& tnlExpBumpFunctionBase< Real >::getSigma() const * 1D */ +template< typename Real > +tnlString +tnlExpBumpFunction< 1, Real >::getType() +{ + return "tnlExpBumpFunction< 1, " + ::getType< Real >() + tnlString( " >" ); +} + template< typename Real > tnlExpBumpFunction< 1, Real >::tnlExpBumpFunction() { } template< typename Real > - template< int XDiffOrder, int YDiffOrder, int ZDiffOrder > - Real tnlExpBumpFunction< 1, Real >::getF( const VertexType& v ) const + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > +Real +tnlExpBumpFunction< 1, Real >::getValue( const Vertex& v, + const Real& time ) const { const RealType& x = v.x(); if( YDiffOrder != 0 || ZDiffOrder != 0 ) @@ -81,16 +96,27 @@ template< typename Real > * 2D */ +template< typename Real > +tnlString +tnlExpBumpFunction< 2, Real >::getType() +{ + return tnlString( "tnlExpBumpFunction< 2, " ) + ::getType< Real >() + " >"; +} + template< typename Real > tnlExpBumpFunction< 2, Real >::tnlExpBumpFunction() { } template< typename Real > - template< int XDiffOrder, int YDiffOrder, int ZDiffOrder > + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > Real tnlExpBumpFunction< 2, Real >:: -getF( const VertexType& v ) const +getValue( const Vertex& v, + const Real& time ) const { const RealType& x = v.x(); const RealType& y = v.y(); @@ -113,16 +139,27 @@ getF( const VertexType& v ) const * 3D */ +template< typename Real > +tnlString +tnlExpBumpFunction< 3, Real >::getType() +{ + return tnlString( "tnlExpBumpFunction< 3, " ) + ::getType< Real >() + " >"; +} + template< typename Real > tnlExpBumpFunction< 3, Real >::tnlExpBumpFunction() { } template< typename Real > - template< int XDiffOrder, int YDiffOrder, int ZDiffOrder > + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > Real tnlExpBumpFunction< 3, Real >:: -getF( const VertexType& v ) const +getValue( const Vertex& v, + const Real& time ) const { const RealType& x = v.x(); const RealType& y = v.y(); diff --git a/src/implementation/functions/tnlFunctionDiscretizer_impl.h b/src/implementation/functions/tnlFunctionDiscretizer_impl.h index 3cff0c7ca8c8253f0c5804369b5356bbbf5a3bc5..70dba155f327928e0ffb5763602d39debe6c2283 100644 --- a/src/implementation/functions/tnlFunctionDiscretizer_impl.h +++ b/src/implementation/functions/tnlFunctionDiscretizer_impl.h @@ -18,23 +18,30 @@ #ifndef TNLFUNCTIONDISCRETIZER_IMPL_H_ #define TNLFUNCTIONDISCRETIZER_IMPL_H_ -template< typename Mesh, typename Function, typename DiscreteFunction > +template< typename Mesh, typename Function, typename Vector > template< int XDiffOrder, int YDiffOrder, int ZDiffOrder > -void tnlFunctionDiscretizer< Mesh, Function, DiscreteFunction >::discretize( const Mesh& mesh, - const Function& function, - DiscreteFunction& discreteFunction ) +void tnlFunctionDiscretizer< Mesh, Function, Vector >::discretize( const Mesh& mesh, + const Function& function, + Vector& discreteFunction ) { //tnlAssert( Mesh::Dimensions == Function::Dimensions, ); // TODO: change this to tnlStaticAssert typename Mesh::IndexType i = 0; discreteFunction.setSize( mesh.getNumberOfCells() ); - while( i < mesh.getNumberOfCells() ) + if( DeviceType::DeviceType == ( int ) tnlHostDevice ) { - typename Mesh::VertexType v; - typename Mesh::CoordinatesType c; - c = mesh.getCellCoordinates( i ); - v = mesh.getCellCenter( c ); - discreteFunction[ i ] = function.template getF< XDiffOrder, YDiffOrder, ZDiffOrder >( v ); - i++; + while( i < mesh.getNumberOfCells() ) + { + typename Mesh::VertexType v; + typename Mesh::CoordinatesType c; + c = mesh.getCellCoordinates( i ); + v = mesh.getCellCenter( c ); + discreteFunction[ i ] = function.template getValue< XDiffOrder, YDiffOrder, ZDiffOrder >( v ); + i++; + } + } + if( DeviceType::DeviceType == ( int ) tnlCudaDevice ) + { + // TODO: implement } } diff --git a/src/implementation/functions/tnlSinBumpsFunction_impl.h b/src/implementation/functions/tnlSinBumpsFunction_impl.h index 76274aa9fa7a95073cc76bb9cc54bda8223b3023..f19161255e60107a997356f281d470b252bc3a33 100644 --- a/src/implementation/functions/tnlSinBumpsFunction_impl.h +++ b/src/implementation/functions/tnlSinBumpsFunction_impl.h @@ -20,38 +20,38 @@ #include <functions/tnlSinBumpsFunction.h> -template< int Dimensions, typename Vertex, typename Device > -void tnlSinBumpsFunctionBase< Dimensions, Vertex, Device >::setWaveLength( const Vertex& waveLength ) +template< typename Vertex > +void tnlSinBumpsFunctionBase< Vertex >::setWaveLength( const Vertex& waveLength ) { this->waveLength = waveLength; } -template< int Dimensions, typename Vertex, typename Device > -const Vertex& tnlSinBumpsFunctionBase< Dimensions, Vertex, Device >::getWaveLength() const +template< typename Vertex > +const Vertex& tnlSinBumpsFunctionBase< Vertex >::getWaveLength() const { return this->waveLength; } -template< int Dimensions, typename Vertex, typename Device > -void tnlSinBumpsFunctionBase< Dimensions, Vertex, Device >::setAmplitude( const typename Vertex::RealType& amplitude ) +template< typename Vertex > +void tnlSinBumpsFunctionBase< Vertex >::setAmplitude( const typename Vertex::RealType& amplitude ) { this->amplitude = amplitude; } -template< int Dimensions, typename Vertex, typename Device > -const typename Vertex::RealType& tnlSinBumpsFunctionBase< Dimensions, Vertex, Device >::getAmplitude() const +template< typename Vertex > +const typename Vertex::RealType& tnlSinBumpsFunctionBase< Vertex >::getAmplitude() const { return this->amplitude; } -template< int Dimensions, typename Vertex, typename Device > -void tnlSinBumpsFunctionBase< Dimensions, Vertex, Device >::setPhase( const Vertex& phase ) +template< typename Vertex > +void tnlSinBumpsFunctionBase< Vertex >::setPhase( const Vertex& phase ) { this->phase = phase; } -template< int Dimensions, typename Vertex, typename Device > -const Vertex& tnlSinBumpsFunctionBase< Dimensions, Vertex, Device >::getPhase() const +template< typename Vertex > +const Vertex& tnlSinBumpsFunctionBase< Vertex >::getPhase() const { return this->phase; } @@ -60,24 +60,31 @@ const Vertex& tnlSinBumpsFunctionBase< Dimensions, Vertex, Device >::getPhase() * 1D */ -template< typename Vertex, typename Device > -tnlSinBumpsFunction< 1, Vertex, Device >::tnlSinBumpsFunction() +template< typename Real > +tnlSinBumpsFunction< 1, Real >::tnlSinBumpsFunction() { } -template< typename Vertex, typename Device > -bool tnlSinBumpsFunction< 1, Vertex, Device >::init( const tnlParameterContainer& parameters ) +template< typename Real > +bool tnlSinBumpsFunction< 1, Real >::init( const tnlParameterContainer& parameters, + const tnlString& prefix ) { - this->amplitude = parameters.GetParameter< double >( "amplitude" ); - this->waveLength.x() = parameters.GetParameter< double >( "wave-length-x" ); - this->phase.x() = parameters.GetParameter< double >( "phase-x" ); + this->amplitude = parameters.GetParameter< double >( prefix + "amplitude" ); + this->waveLength.x() = parameters.GetParameter< double >( prefix + "wave-length-x" ); + this->phase.x() = parameters.GetParameter< double >( prefix + "phase-x" ); return true; } -template< typename Vertex, typename Device > - template< int XDiffOrder, int YDiffOrder, int ZDiffOrder > - typename Vertex::RealType tnlSinBumpsFunction< 1, Vertex, Device >::getF( const Vertex& v ) const +template< typename Real > + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > +Real +tnlSinBumpsFunction< 1, Real >:: +getValue( const Vertex& v, + const Real& time ) const { const RealType& x = v.x(); if( YDiffOrder != 0 || ZDiffOrder != 0 ) @@ -95,26 +102,33 @@ template< typename Vertex, typename Device > * 2D */ -template< typename Vertex, typename Device > -tnlSinBumpsFunction< 2, Vertex, Device >::tnlSinBumpsFunction() +template< typename Real > +tnlSinBumpsFunction< 2, Real >::tnlSinBumpsFunction() { } -template< typename Vertex, typename Device > -bool tnlSinBumpsFunction< 2, Vertex, Device >::init( const tnlParameterContainer& parameters ) +template< typename Real > +bool tnlSinBumpsFunction< 2, Real >::init( const tnlParameterContainer& parameters, + const tnlString& prefix ) { - this->amplitude = parameters.GetParameter< double >( "amplitude" ); - this->waveLength.x() = parameters.GetParameter< double >( "wave-length-x" ); - this->waveLength.y() = parameters.GetParameter< double >( "wave-length-y" ); - this->phase.x() = parameters.GetParameter< double >( "phase-x" ); - this->phase.y() = parameters.GetParameter< double >( "phase-y" ); + this->amplitude = parameters.GetParameter< double >( prefix + "amplitude" ); + this->waveLength.x() = parameters.GetParameter< double >( prefix + "wave-length-x" ); + this->waveLength.y() = parameters.GetParameter< double >( prefix + "wave-length-y" ); + this->phase.x() = parameters.GetParameter< double >( prefix + "phase-x" ); + this->phase.y() = parameters.GetParameter< double >( prefix + "phase-y" ); return true; } -template< typename Vertex, typename Device > - template< int XDiffOrder, int YDiffOrder, int ZDiffOrder > - typename Vertex::RealType tnlSinBumpsFunction< 2, Vertex, Device >::getF( const Vertex& v ) const +template< typename Real > + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > +Real +tnlSinBumpsFunction< 2, Real>:: +getValue( const Vertex& v, + const Real& time ) const { const RealType& x = v.x(); const RealType& y = v.y(); @@ -139,28 +153,35 @@ template< typename Vertex, typename Device > * 3D */ -template< typename Vertex, typename Device > -tnlSinBumpsFunction< 3, Vertex, Device >::tnlSinBumpsFunction() +template< typename Real > +tnlSinBumpsFunction< 3, Real >::tnlSinBumpsFunction() { } -template< typename Vertex, typename Device > -bool tnlSinBumpsFunction< 3, Vertex, Device >::init( const tnlParameterContainer& parameters ) +template< typename Real > +bool tnlSinBumpsFunction< 3, Real >::init( const tnlParameterContainer& parameters, + const tnlString& prefix ) { - this->amplitude = parameters.GetParameter< double >( "amplitude" ); - this->waveLength.x() = parameters.GetParameter< double >( "wave-length-x" ); - this->waveLength.y() = parameters.GetParameter< double >( "wave-length-y" ); - this->waveLength.z() = parameters.GetParameter< double >( "wave-length-z" ); - this->phase.x() = parameters.GetParameter< double >( "phase-x" ); - this->phase.y() = parameters.GetParameter< double >( "phase-y" ); - this->phase.z() = parameters.GetParameter< double >( "phase-z" ); + this->amplitude = parameters.GetParameter< double >( prefix + "amplitude" ); + this->waveLength.x() = parameters.GetParameter< double >( prefix + "wave-length-x" ); + this->waveLength.y() = parameters.GetParameter< double >( prefix + "wave-length-y" ); + this->waveLength.z() = parameters.GetParameter< double >( prefix + "wave-length-z" ); + this->phase.x() = parameters.GetParameter< double >( prefix + "phase-x" ); + this->phase.y() = parameters.GetParameter< double >( prefix + "phase-y" ); + this->phase.z() = parameters.GetParameter< double >( prefix + "phase-z" ); return true; } -template< typename Vertex, typename Device > - template< int XDiffOrder, int YDiffOrder, int ZDiffOrder > - typename Vertex::RealType tnlSinBumpsFunction< 3, Vertex, Device >::getF( const Vertex& v ) const +template< typename Real > + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > +Real +tnlSinBumpsFunction< 3, Real >:: +getValue( const Vertex& v, + const Real& time ) const { const RealType& x = v.x(); const RealType& y = v.y(); diff --git a/src/implementation/functions/tnlSinWaveFunction_impl.h b/src/implementation/functions/tnlSinWaveFunction_impl.h index b0274f40d8a165c8a20ca017a144514e95713e27..bd8ecfa8b07d290d9f951b61a81e0b4cf63356c8 100644 --- a/src/implementation/functions/tnlSinWaveFunction_impl.h +++ b/src/implementation/functions/tnlSinWaveFunction_impl.h @@ -30,12 +30,13 @@ tnlSinWaveFunctionBase< Real >::tnlSinWaveFunctionBase() } template< typename Real > -bool tnlSinWaveFunctionBase< Real >::init( const tnlParameterContainer& parameters ) +bool tnlSinWaveFunctionBase< Real >::init( const tnlParameterContainer& parameters, + const tnlString& prefix ) { - this->waveLength = parameters.GetParameter< double >( "wave-length" ); - this->amplitude = parameters.GetParameter< double >( "amplitude" ); - this->phase = parameters.GetParameter< double >( "phase" ); - parameters.GetParameter< double >( "waves-number" ); + this->waveLength = parameters.GetParameter< double >( prefix + "wave-length" ); + this->amplitude = parameters.GetParameter< double >( prefix + "amplitude" ); + this->phase = parameters.GetParameter< double >( prefix + "phase" ); + parameters.GetParameter< double >( prefix + "waves-number" ); return true; } @@ -75,9 +76,15 @@ Real tnlSinWaveFunctionBase< Real >::getPhase() const return this->phase; } -template< typename Vertex, typename Device > - template< int XDiffOrder, int YDiffOrder, int ZDiffOrder > - typename Vertex::RealType tnlSinWaveFunction< 1, Vertex, Device >::getF( const Vertex& v ) const +template< typename Real > + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > +Real +tnlSinWaveFunction< 1, Real >:: +getValue( const Vertex& v, + const Real& time ) const { const RealType& x = v.x(); if( YDiffOrder != 0 || ZDiffOrder != 0 ) @@ -100,9 +107,15 @@ template< typename Vertex, typename Device > } -template< typename Vertex, typename Device > - template< int XDiffOrder, int YDiffOrder, int ZDiffOrder > - typename Vertex::RealType tnlSinWaveFunction< 2, Vertex, Device >::getF( const VertexType& v ) const +template< typename Real > + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > +Real +tnlSinWaveFunction< 2, Real >:: +getValue( const Vertex& v, + const Real& time ) const { const RealType& x = v.x(); const RealType& y = v.y(); @@ -123,9 +136,15 @@ template< typename Vertex, typename Device > return 0.0; } -template< typename Vertex, typename Device > - template< int XDiffOrder, int YDiffOrder, int ZDiffOrder > - typename Vertex::RealType tnlSinWaveFunction< 3, Vertex, Device >::getF( const VertexType& v ) const +template< typename Real > + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > +Real +tnlSinWaveFunction< 3, Real >:: +getValue( const Vertex& v, + const Real& time ) const { const RealType& x = v.x(); const RealType& y = v.y(); diff --git a/src/implementation/functions/tnlTestFunction_impl.h b/src/implementation/functions/tnlTestFunction_impl.h index b05494aa58f81199f8d03240f586ec258293c17a..c4a8a78a3ef396bf93e8d74f0baddbdab3c45e6d 100644 --- a/src/implementation/functions/tnlTestFunction_impl.h +++ b/src/implementation/functions/tnlTestFunction_impl.h @@ -18,6 +18,7 @@ #ifndef TNLTESTFUNCTION_IMPL_H_ #define TNLTESTFUNCTION_IMPL_H_ +#include <core/tnlCuda.h> #include <functions/tnlConstantFunction.h> #include <functions/tnlExpBumpFunction.h> #include <functions/tnlSinBumpsFunction.h> @@ -29,34 +30,75 @@ template< int FunctionDimensions, tnlTestFunction< FunctionDimensions, Real, Device >:: tnlTestFunction() : function( 0 ), - functionType( none ) + timeDependence( none ), + timeScale( 1.0 ) { } +template< int FunctionDimensions, + typename Real, + typename Device > +void +tnlTestFunction< FunctionDimensions, Real, Device >:: +configSetup( tnlConfigDescription& config, + const tnlString& prefix ) +{ + config.addEntry < tnlString >( "test-function", "Testing function.", "exp-bump" ); + config.addEntryEnum( "sin-wave" ); + config.addEntryEnum( "sin-bumps" ); + config.addEntryEnum( "exp-bump" ); + config.addEntry < double >( prefix + "value", "Value of the constant function.", 0.0 ); + config.addEntry < double >( prefix + "wave-length", "Wave length of the sine based test functions.", 1.0 ); + config.addEntry < double >( prefix + "wave-length-x", "Wave length of the sine based test functions.", 1.0 ); + config.addEntry < double >( prefix + "wave-length-y", "Wave length of the sine based test functions.", 1.0 ); + config.addEntry < double >( prefix + "wave-length-z", "Wave length of the sine based test functions.", 1.0 ); + config.addEntry < double >( prefix + "phase", "Phase of the sine based test functions.", 0.0 ); + config.addEntry < double >( prefix + "phase-x", "Phase of the sine based test functions.", 0.0 ); + config.addEntry < double >( prefix + "phase-y", "Phase of the sine based test functions.", 0.0 ); + config.addEntry < double >( prefix + "phase-z", "Phase of the sine based test functions.", 0.0 ); + config.addEntry < double >( prefix + "amplitude", "Amplitude length of the sine based test functions.", 1.0 ); + config.addEntry < double >( prefix + "waves-number", "Cut-off for the sine based test functions.", 0.0 ); + config.addEntry < double >( prefix + "waves-number-x", "Cut-off for the sine based test functions.", 0.0 ); + config.addEntry < double >( prefix + "waves-number-y", "Cut-off for the sine based test functions.", 0.0 ); + config.addEntry < double >( prefix + "waves-number-z", "Cut-off for the sine based test functions.", 0.0 ); + config.addEntry < double >( prefix + "sigma", "Sigma for the exp based test functions.", 1.0 ); + config.addEntry < tnlString >( "test-function-time-dependence", "Time dependence of the test function.", "none" ); + config.addEntryEnum( "none" ); + config.addEntryEnum( "linear" ); + config.addEntryEnum( "quadratic" ); + config.addEntryEnum( "cosine" ); + config.addEntry < double >( prefix + "time-scale", "Time scaling for the time dependenc of the test function.", 1.0 ); + +} + template< int FunctionDimensions, typename Real, typename Device > template< typename FunctionType > bool tnlTestFunction< FunctionDimensions, Real, Device >:: -initFunction( const tnlParameterContainer& parameters ) +initFunction( const tnlParameterContainer& parameters, + const tnlString& prefix ) { FunctionType* auxFunction = new FunctionType; - if( ! auxFunction->init( parameters ) ) + if( ! auxFunction->init( parameters, prefix ) ) { delete auxFunction; return false; } - if( Device::DeviceType == tnlHostDevice ) + if( Device::DeviceType == ( int ) tnlHostDevice ) { function = auxFunction; } - if( Device::DeviceType == tnlCudaDevice ) + if( Device::DeviceType == ( int ) tnlCudaDevice ) { - function = passToDevice( *auxFunction ); + function = tnlCuda::passToDevice( *auxFunction ); delete auxFunction; + if( ! checkCudaDevice ) + return false; } + return true; } template< int FunctionDimensions, @@ -64,7 +106,8 @@ template< int FunctionDimensions, typename Device > bool tnlTestFunction< FunctionDimensions, Real, Device >:: -init( const tnlParameterContainer& parameters ) +init( const tnlParameterContainer& parameters, + const tnlString& prefix ) { const tnlString& testFunction = parameters.GetParameter< tnlString >( "test-function" ); @@ -92,32 +135,123 @@ init( const tnlParameterContainer& parameters ) functionType = sinWave; return initFunction< FunctionType >( parameters ); } + + const tnlString& timeDependence = parameters.GetParameter< tnlString >( "test-function-time-dependence" ); + if( timeDependence == "none" ) + this->timeDependence = none; + if( timeDependence == "linear" ) + this->timeDependence = linear; + if( timeDependence == "quadratic" ) + this->timeDependence = quadratic; + if( timeDependence == "sine" ) + this->timeDependence = sine; + + this->timeScale = parameters.GetParameter< tnlString >( "time-scale" ); } template< int FunctionDimensions, typename Real, typename Device > - template< typename Vertex > + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > #ifdef HAVE_CUDA __device__ __host__ #endif Real tnlTestFunction< FunctionDimensions, Real, Device >:: -getValue( const Vertex& vertex ) const +getValue( const Vertex& vertex, + const Real& time ) const { + Real scale( 1.0 ); + switch( timeDependence ) + { + case none: + break; + case linear: + scale = 1.0 - this->timeScale * time; + break; + case quadratic: + scale = this->timeScale * time; + scale *= scale; + scale = 1.0 - scale; + break; + case sine: + scale = 1.0 - sin( this->timeScale * time ); + break; + } switch( functionType ) { case constant: - return ( ( tnlConstantFunction< Dimensions, Real >* ) function )->getValue( vertex ); + return scale * ( ( tnlConstantFunction< Dimensions, Real >* ) function )-> + getValue< XDiffOrder, YDiffOrder, ZDiffOrder, Vertex >( vertex, time ); break; case expBump: - return ( ( tnlExpBumpFunction< Dimensions, Real >* ) function )->getValue( vertex ); + return scale * ( ( tnlExpBumpFunction< Dimensions, Real >* ) function )-> + getValue< XDiffOrder, YDiffOrder, ZDiffOrder, Vertex >( vertex, time ); break; case sinBumps: - return ( ( tnlSinBumpsFunction< Dimensions, Real >* ) function )->getValue( vertex ); + return scale * ( ( tnlSinBumpsFunction< Dimensions, Real >* ) function )-> + getValue< XDiffOrder, YDiffOrder, ZDiffOrder, Vertex >( vertex, time ); break; case sinWave: - return ( ( tnlSinWaveFunction< Dimensions, Real >* ) function )->getValue( vertex ); + return scale * ( ( tnlSinWaveFunction< Dimensions, Real >* ) function )-> + getValue< XDiffOrder, YDiffOrder, ZDiffOrder, Vertex >( vertex, time ); + break; + default: + return 0.0; + break; + } +} + +template< int FunctionDimensions, + typename Real, + typename Device > + template< int XDiffOrder, + int YDiffOrder, + int ZDiffOrder, + typename Vertex > +#ifdef HAVE_CUDA +__device__ __host__ +#endif +Real +tnlTestFunction< FunctionDimensions, Real, Device >:: +getTimeDerivative( const Vertex& vertex, + const Real& time ) const +{ + Real scale( 0.0 ); + switch( timeDependence ) + { + case none: + break; + case linear: + scale = -this->timeScale; + break; + case quadratic: + scale = -2.0 * this->timeScale * this->timeScale * time; + break; + case sine: + scale = -this->timeScale * cos( this->timeScale * time ); + break; + } + switch( functionType ) + { + case constant: + return scale * ( ( tnlConstantFunction< Dimensions, Real >* ) function )-> + getValue< XDiffOrder, YDiffOrder, ZDiffOrder, Vertex >( vertex, time ); + break; + case expBump: + return scale * ( ( tnlExpBumpFunction< Dimensions, Real >* ) function )-> + getValue< XDiffOrder, YDiffOrder, ZDiffOrder, Vertex >( vertex, time ); + break; + case sinBumps: + return scale * ( ( tnlSinBumpsFunction< Dimensions, Real >* ) function )-> + getValue< XDiffOrder, YDiffOrder, ZDiffOrder, Vertex >( vertex, time ); + break; + case sinWave: + return scale * ( ( tnlSinWaveFunction< Dimensions, Real >* ) function )-> + getValue< XDiffOrder, YDiffOrder, ZDiffOrder, Vertex >( vertex, time ); break; default: return 0.0; @@ -133,9 +267,9 @@ void tnlTestFunction< FunctionDimensions, Real, Device >:: deleteFunction() { - if( Device::DeviceType == tnlHostDevice ) + if( Device::DeviceType == ( int ) tnlHostDevice ) delete ( FunctionType * ) function; - if( Device::DeviceType == tnlCudaDevice ) + if( Device::DeviceType == ( int ) tnlCudaDevice ) tnlCuda::freeFromDevice( ( FunctionType * ) function ); } @@ -159,11 +293,7 @@ tnlTestFunction< FunctionDimensions, Real, Device >:: case sinWave: deleteFunction< tnlSinWaveFunction< Dimensions, Real> >(); break; - - } - - } diff --git a/src/implementation/matrices/tnlCSRMatrix_impl.h b/src/implementation/matrices/tnlCSRMatrix_impl.h index aeb1453a0656ba2144231fec6ef4ca5944707bcb..b48a238f2b694fbc86708841fbd853b520c109e3 100644 --- a/src/implementation/matrices/tnlCSRMatrix_impl.h +++ b/src/implementation/matrices/tnlCSRMatrix_impl.h @@ -39,7 +39,7 @@ template< typename Real, tnlString tnlCSRMatrix< Real, Device, Index >::getType() { return tnlString( "tnlCSRMatrix< ") + - tnlString( getParameterType< Real>() ) + + tnlString( ::getType< Real>() ) + tnlString( ", " ) + Device :: getDeviceType() + tnlString( " >" ); diff --git a/src/implementation/matrices/tnlChunkedEllpackMatrix_impl.h b/src/implementation/matrices/tnlChunkedEllpackMatrix_impl.h index 41da772309f1718cbb49fbc1deddd814345db381..1e3227e4a74658f7cb2f206fb067a1b77ca97d99 100644 --- a/src/implementation/matrices/tnlChunkedEllpackMatrix_impl.h +++ b/src/implementation/matrices/tnlChunkedEllpackMatrix_impl.h @@ -56,7 +56,7 @@ template< typename Real, tnlString tnlChunkedEllpackMatrix< Real, Device, Index >::getType() { return tnlString( "tnlChunkedEllpackMatrix< ") + - tnlString( getParameterType< Real >() ) + + tnlString( ::getType< Real >() ) + tnlString( ", " ) + Device :: getDeviceType() + tnlString( " >" ); diff --git a/src/implementation/matrices/tnlDenseMatrix_impl.h b/src/implementation/matrices/tnlDenseMatrix_impl.h index acbb3cfd56d3123a7d52663bc47e9818b3a531e9..4d41844018405abcd8937b011ff4960d20018721 100644 --- a/src/implementation/matrices/tnlDenseMatrix_impl.h +++ b/src/implementation/matrices/tnlDenseMatrix_impl.h @@ -38,9 +38,9 @@ template< typename Real, tnlString tnlDenseMatrix< Real, Device, Index >::getType() { return tnlString( "tnlDenseMatrix< " ) + - tnlString( getParameterType< RealType >() ) + ", " + + tnlString( ::getType< RealType >() ) + ", " + tnlString( Device :: getDeviceType() ) + ", " + - tnlString( getParameterType< IndexType >() ) + " >"; + tnlString( ::getType< IndexType >() ) + " >"; } template< typename Real, diff --git a/src/implementation/matrices/tnlEllpackMatrix_impl.h b/src/implementation/matrices/tnlEllpackMatrix_impl.h index 08f2e30e68b3c35b82f9e440c636f778568e6846..1257741aefed7370877eaebc851251a108e563dd 100644 --- a/src/implementation/matrices/tnlEllpackMatrix_impl.h +++ b/src/implementation/matrices/tnlEllpackMatrix_impl.h @@ -36,7 +36,7 @@ template< typename Real, tnlString tnlEllpackMatrix< Real, Device, Index > :: getType() { return tnlString( "tnlEllpackMatrix< ") + - tnlString( getParameterType< Real >() ) + + tnlString( ::getType< Real >() ) + tnlString( ", " ) + Device :: getDeviceType() + tnlString( " >" ); @@ -61,7 +61,7 @@ bool tnlEllpackMatrix< Real, Device, Index >::setDimensions( const IndexType row << " columns = " << columns << endl ); this->rows = rows; this->columns = columns; - if( Device::DeviceType == tnlCudaDevice ) + if( Device::DeviceType == ( int ) tnlCudaDevice ) this->alignedRows = roundToMultiple( columns, tnlCuda::getWarpSize() ); else this->alignedRows = rows; if( this->rowLengths != 0 ) diff --git a/src/implementation/matrices/tnlMultidiagonalMatrix_impl.h b/src/implementation/matrices/tnlMultidiagonalMatrix_impl.h index 41d415522ee5d072c1b533a52b23f1fd0fbd7abb..f24c3935a991b5b9ac8d1717f2099c7d65e667b7 100644 --- a/src/implementation/matrices/tnlMultidiagonalMatrix_impl.h +++ b/src/implementation/matrices/tnlMultidiagonalMatrix_impl.h @@ -38,7 +38,7 @@ template< typename Real, tnlString tnlMultidiagonalMatrix< Real, Device, Index > :: getType() { return tnlString( "tnlMultidiagonalMatrix< ") + - tnlString( getParameterType< Real >() ) + + tnlString( ::getType< Real >() ) + tnlString( ", " ) + Device :: getDeviceType() + tnlString( " >" ); diff --git a/src/implementation/matrices/tnlSlicedEllpackMatrix_impl.h b/src/implementation/matrices/tnlSlicedEllpackMatrix_impl.h index 35b04716c2dc9cb46fbcde644093e3a8b9432393..203087460d471eb373e282f70bb5a1e031fb912a 100644 --- a/src/implementation/matrices/tnlSlicedEllpackMatrix_impl.h +++ b/src/implementation/matrices/tnlSlicedEllpackMatrix_impl.h @@ -37,7 +37,7 @@ template< typename Real, tnlString tnlSlicedEllpackMatrix< Real, Device, Index, SliceSize >::getType() { return tnlString( "tnlSlicedEllpackMatrix< ") + - tnlString( getParameterType< Real >() ) + + tnlString( ::getType< Real >() ) + tnlString( ", " ) + Device :: getDeviceType() + tnlString( " >" ); diff --git a/src/implementation/matrices/tnlTridiagonalMatrix_impl.h b/src/implementation/matrices/tnlTridiagonalMatrix_impl.h index 761e2203172bbfeb6982493976ded35da9b374c4..363391a28263ad7c74a6a3931c75f46da09b42b8 100644 --- a/src/implementation/matrices/tnlTridiagonalMatrix_impl.h +++ b/src/implementation/matrices/tnlTridiagonalMatrix_impl.h @@ -37,9 +37,9 @@ template< typename Real, tnlString tnlTridiagonalMatrix< Real, Device, Index >::getType() { return tnlString( "tnlTridiagonalMatrix< " ) + - tnlString( getParameterType< RealType >() ) + ", " + + tnlString( ::getType< RealType >() ) + ", " + tnlString( Device :: getDeviceType() ) + ", " + - tnlString( getParameterType< IndexType >() ) + " >"; + tnlString( ::getType< IndexType >() ) + " >"; } template< typename Real, diff --git a/src/implementation/mesh/tnlGrid1D_impl.h b/src/implementation/mesh/tnlGrid1D_impl.h index b8db5836b907c71d94b446e6aa630f6d702fa4ca..989b25d1b914079c0c0dec3b167eeec7b1d9becc 100644 --- a/src/implementation/mesh/tnlGrid1D_impl.h +++ b/src/implementation/mesh/tnlGrid1D_impl.h @@ -42,9 +42,9 @@ tnlString tnlGrid< 1, Real, Device, Index > :: getType() { return tnlString( "tnlGrid< " ) + tnlString( Dimensions ) + ", " + - tnlString( getParameterType< RealType >() ) + ", " + + tnlString( ::getType< RealType >() ) + ", " + tnlString( Device :: getDeviceType() ) + ", " + - tnlString( getParameterType< IndexType >() ) + " >"; + tnlString( ::getType< IndexType >() ) + " >"; } template< typename Real, @@ -301,6 +301,22 @@ Vertex tnlGrid< 1, Real, Device, Index >::getCellCenter( const CoordinatesType& return this->origin.x() + ( cellCoordinates.x() + 0.5 ) * this->cellProportions.x(); } +template< typename Real, + typename Device, + typename Index > + template< typename Vertex > +#ifdef HAVE_CUDA + __device__ __host__ +#endif +Vertex tnlGrid< 1, Real, Device, Index >::getCellCenter( const IndexType& cellIndex ) const +{ + tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), + cerr << " cellIndex = " << cellIndex + << " this->getNumberOfCells() = " << this->getNumberOfCells() + << " this->getName() " << this->getName(); ); + return this->getCellCenter( this->getCellCoordinates( cellIndex ) ); +} + template< typename Real, typename Device, typename Index > @@ -356,6 +372,23 @@ bool tnlGrid< 1, Real, Device, Index > :: isBoundaryCell( const CoordinatesType& return false; } +template< typename Real, + typename Device, + typename Index > +#ifdef HAVE_CUDA + __device__ __host__ +#endif +bool +tnlGrid< 1, Real, Device, Index >:: +isBoundaryCell( const IndexType& cellIndex ) const +{ + tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), + cerr << " cellIndex = " << cellIndex + << " this->getNumberOfCells() = " << this->getNumberOfCells() + << " this->getName() " << this->getName(); ); + return this->isBoundaryCell( this->getCellCoordinates( cellIndex ) ); +} + template< typename Real, typename Device, typename Index > diff --git a/src/implementation/mesh/tnlGrid2D_impl.h b/src/implementation/mesh/tnlGrid2D_impl.h index b7bfdde4cff46a49f7241fcd0de800e3e359ad46..8434265858b3bf75970b3452af2249096970e65e 100644 --- a/src/implementation/mesh/tnlGrid2D_impl.h +++ b/src/implementation/mesh/tnlGrid2D_impl.h @@ -44,9 +44,9 @@ tnlString tnlGrid< 2, Real, Device, Index > :: getType() { return tnlString( "tnlGrid< " ) + tnlString( Dimensions ) + ", " + - tnlString( getParameterType< RealType >() ) + ", " + + tnlString( ::getType< RealType >() ) + ", " + tnlString( Device :: getDeviceType() ) + ", " + - tnlString( getParameterType< IndexType >() ) + " >"; + tnlString( ::getType< IndexType >() ) + " >"; } template< typename Real, @@ -488,6 +488,22 @@ Vertex tnlGrid< 2, Real, Device, Index > :: getCellCenter( const CoordinatesType this->origin.y() + ( cellCoordinates.y() + 0.5 ) * this->cellProportions.y() ); } +template< typename Real, + typename Device, + typename Index > + template< typename Vertex > +#ifdef HAVE_CUDA + __device__ __host__ +#endif +Vertex tnlGrid< 2, Real, Device, Index >::getCellCenter( const IndexType& cellIndex ) const +{ + tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), + cerr << " cellIndex = " << cellIndex + << " this->getNumberOfCells() = " << this->getNumberOfCells() + << " this->getName() " << this->getName(); ); + return this->getCellCenter( this->getCellCoordinates( cellIndex ) ); +} + template< typename Real, typename Device, typename Index > @@ -605,6 +621,25 @@ bool tnlGrid< 2, Real, Device, Index > :: isBoundaryCell( const CoordinatesType& return false; } + +template< typename Real, + typename Device, + typename Index > +#ifdef HAVE_CUDA + __device__ __host__ +#endif +bool +tnlGrid< 2, Real, Device, Index >:: +isBoundaryCell( const IndexType& cellIndex ) const +{ + tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), + cerr << " cellIndex = " << cellIndex + << " this->getNumberOfCells() = " << this->getNumberOfCells() + << " this->getName() " << this->getName(); ); + return this->isBoundaryCell( this->getCellCoordinates( cellIndex ) ); +} + + template< typename Real, typename Device, typename Index > diff --git a/src/implementation/mesh/tnlGrid3D_impl.h b/src/implementation/mesh/tnlGrid3D_impl.h index 531319b760ac85b27df8377821d1921b021f12ca..cb22d46ba92ebd7125dc52e2a4a10004d1955acf 100644 --- a/src/implementation/mesh/tnlGrid3D_impl.h +++ b/src/implementation/mesh/tnlGrid3D_impl.h @@ -47,9 +47,9 @@ tnlString tnlGrid< 3, Real, Device, Index > :: getType() { return tnlString( "tnlGrid< " ) + tnlString( Dimensions ) + ", " + - tnlString( getParameterType< RealType >() ) + ", " + + tnlString( ::getType< RealType >() ) + ", " + tnlString( Device :: getDeviceType() ) + ", " + - tnlString( getParameterType< IndexType >() ) + " >"; + tnlString( ::getType< IndexType >() ) + " >"; } template< typename Real, @@ -805,6 +805,22 @@ Vertex tnlGrid< 3, Real, Device, Index > :: getCellCenter( const CoordinatesType this->origin.z() + ( cellCoordinates.z() + 0.5 ) * this->cellProportions.z() ); } +template< typename Real, + typename Device, + typename Index > + template< typename Vertex > +#ifdef HAVE_CUDA + __device__ __host__ +#endif +Vertex tnlGrid< 3, Real, Device, Index >::getCellCenter( const IndexType& cellIndex ) const +{ + tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), + cerr << " cellIndex = " << cellIndex + << " this->getNumberOfCells() = " << this->getNumberOfCells() + << " this->getName() " << this->getName(); ); + return this->getCellCenter( this->getCellCoordinates( cellIndex ) ); +} + template< typename Real, typename Device, typename Index > @@ -1038,6 +1054,23 @@ bool tnlGrid< 3, Real, Device, Index > :: isBoundaryCell( const CoordinatesType& return false; } +template< typename Real, + typename Device, + typename Index > +#ifdef HAVE_CUDA + __device__ __host__ +#endif +bool +tnlGrid< 3, Real, Device, Index >:: +isBoundaryCell( const IndexType& cellIndex ) const +{ + tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), + cerr << " cellIndex = " << cellIndex + << " this->getNumberOfCells() = " << this->getNumberOfCells() + << " this->getName() " << this->getName(); ); + return this->isBoundaryCell( this->getCellCoordinates( cellIndex ) ); +} + template< typename Real, typename Device, typename Index > diff --git a/src/implementation/operators/CMakeLists.txt b/src/implementation/operators/CMakeLists.txt new file mode 100755 index 0000000000000000000000000000000000000000..84992d01813025ac05ee131684d5fff3eed88042 --- /dev/null +++ b/src/implementation/operators/CMakeLists.txt @@ -0,0 +1,23 @@ +ADD_SUBDIRECTORY( gradient ) +ADD_SUBDIRECTORY( diffusion ) +ADD_SUBDIRECTORY( euler ) + +SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/implementation/operators ) + +if( BUILD_CUDA) + set( tnl_implementation_operators_CUDA__SOURCES + ${tnl_implementation_operators_diffusion_CUDA__SOURCES} + ${tnl_implementation_operators_gradient_CUDA__SOURCES} + ${tnl_implementation_operators_euler_CUDA__SOURCES} + ${common_SOURCES} + PARENT_SCOPE ) +endif() + +set( tnl_implementation_operators_SOURCES + ${tnl_implementation_operators_diffusion_SOURCES} + ${tnl_implementation_operators_gradient_SOURCES} + ${tnl_implementation_operators_euler_SOURCES} + ${common_SOURCES} + PARENT_SCOPE ) + +INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/implementation/operators ) diff --git a/src/implementation/schemes/diffusion/CMakeLists.txt b/src/implementation/operators/diffusion/CMakeLists.txt similarity index 100% rename from src/implementation/schemes/diffusion/CMakeLists.txt rename to src/implementation/operators/diffusion/CMakeLists.txt diff --git a/src/implementation/operators/diffusion/tnlExactLinearDiffusion_impl.h b/src/implementation/operators/diffusion/tnlExactLinearDiffusion_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..fa004a3eff63a7dac6b9b84c3e2363c69ab4b916 --- /dev/null +++ b/src/implementation/operators/diffusion/tnlExactLinearDiffusion_impl.h @@ -0,0 +1,76 @@ +/*************************************************************************** + tnlExactLinearDiffusion_impl.h - description + ------------------- + begin : Aug 8, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TNLEXACTLINEARDIFFUSION_IMPL_H_ +#define TNLEXACTLINEARDIFFUSION_IMPL_H_ + +tnlString +tnlExactLinearDiffusion< 1 >:: +getType() +{ + return "tnlExactLinearDiffusion< 1 >"; +} + +template< typename Function, typename Vertex, typename Real > +Real +tnlExactLinearDiffusion< 1 >:: +getValue( const Function& function, + const Vertex& v, + const Real& time ) +{ + return function.template getValue< 2 >( v, time ); +} + +tnlString +tnlExactLinearDiffusion< 2 >:: +getType() +{ + return "tnlExactLinearDiffusion< 2 >"; +} + +template< typename Function, typename Vertex, typename Real > +Real +tnlExactLinearDiffusion< 2 >:: +getValue( const Function& function, + const Vertex& v, + const Real& time ) +{ + return function.template getValue< 2, 0 >( v, time ) + + function.template getValue< 0, 2 >( v, time ); +} + +tnlString +tnlExactLinearDiffusion< 3 >:: +getType() +{ + return "tnlExactLinearDiffusion< 3 >"; +} + +template< typename Function, typename Vertex, typename Real > +Real +tnlExactLinearDiffusion< 3 >:: +getValue( const Function& function, + const Vertex& v, + const Real& time ) +{ + return function.template getValue< 2, 0, 0 >( v, time ) + + function.template getValue< 0, 2, 0 >( v, time ) + + function.template getValue< 0, 0, 2 >( v, time ); + +} + +#endif /* TNLEXACTLINEARDIFFUSION_IMPL_H_ */ diff --git a/src/implementation/operators/diffusion/tnlLinearDiffusion_impl.h b/src/implementation/operators/diffusion/tnlLinearDiffusion_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..aafdee32a526c4889478f8feb2fa40cdd41fd106 --- /dev/null +++ b/src/implementation/operators/diffusion/tnlLinearDiffusion_impl.h @@ -0,0 +1,204 @@ + +#ifndef TNLLINEARDIFFUSION_IMP_H +#define TNLLINEARDIFFUSION_IMP_H + +#include <operators/diffusion/tnlLinearDiffusion.h> +#include <mesh/tnlGrid.h> + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +tnlString +tnlLinearDiffusion< tnlGrid< 1, MeshReal, Device, MeshIndex >, Real, Index >:: +getType() +{ + return tnlString( "tnlLinearDiffusion< " ) + + MeshType::getType() + ", " + + ::getType< Real >() + ", " + + ::getType< Index >() + " >"; +} + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > + template< typename Vector > +#ifdef HAVE_CUDA +__device__ __host__ +#endif +void +tnlLinearDiffusion< tnlGrid< 1, MeshReal, Device, MeshIndex >, Real, Index >:: +explicitUpdate( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType cellIndex, + const CoordinatesType& coordinates, + Vector& u, + Vector& fu ) const +{ + fu[ cellIndex ] = ( u[ mesh.getCellXPredecessor( cellIndex ) ] + - 2.0 * u[ cellIndex ] + + u[ mesh.getCellXSuccessor( cellIndex ) ] ) * mesh.getHxSquareInverse(); +} + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +template< typename Vector > +#ifdef HAVE_CUDA +__device__ __host__ +#endif +Real +tnlLinearDiffusion< tnlGrid< 1, MeshReal, Device, MeshIndex >, Real, Index >:: +getValue( const MeshType& mesh, + const IndexType cellIndex, + Vector& u ) const +{ + return ( u[ mesh.getCellXPredecessor( cellIndex ) ] + - 2.0 * u[ cellIndex ] + + u[ mesh.getCellXSuccessor( cellIndex ) ] ) * mesh.getHxSquareInverse(); +} + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +tnlString +tnlLinearDiffusion< tnlGrid< 2, MeshReal, Device, MeshIndex >, Real, Index >:: +getType() +{ + return tnlString( "tnlLinearDiffusion< " ) + + MeshType::getType() + ", " + + ::getType< Real >() + ", " + + ::getType< Index >() + " >"; +} + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > + template< typename Vector > +#ifdef HAVE_CUDA +__device__ __host__ +#endif +void +tnlLinearDiffusion< tnlGrid< 2, MeshReal, Device, MeshIndex >, Real, Index >:: +explicitUpdate( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType cellIndex, + const CoordinatesType& coordinates, + Vector& u, + Vector& fu ) const +{ + fu[ cellIndex ] = ( u[ mesh.getCellXPredecessor( cellIndex ) ] + - 2.0 * u[ cellIndex ] + + u[ mesh.getCellXSuccessor( cellIndex ) ] ) * mesh.getHxSquareInverse() + + ( u[ mesh.getCellYPredecessor( cellIndex ) ] + - 2.0 * u[ cellIndex ] + + u[ mesh.getCellYSuccessor( cellIndex ) ] ) * mesh.getHySquareInverse(); +} + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +template< typename Vector > +#ifdef HAVE_CUDA +__device__ __host__ +#endif +Real +tnlLinearDiffusion< tnlGrid< 2, MeshReal, Device, MeshIndex >, Real, Index >:: +getValue( const MeshType& mesh, + const IndexType cellIndex, + Vector& u ) const +{ + return ( u[ mesh.getCellXPredecessor( cellIndex ) ] + - 2.0 * u[ cellIndex ] + + u[ mesh.getCellXSuccessor( cellIndex ) ] ) * mesh.getHxSquareInverse() + + ( u[ mesh.getCellYPredecessor( cellIndex ) ] + - 2.0 * u[ cellIndex ] + + u[ mesh.getCellYSuccessor( cellIndex ) ] ) * mesh.getHySquareInverse(); +} + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +tnlString +tnlLinearDiffusion< tnlGrid< 3, MeshReal, Device, MeshIndex >, Real, Index >:: +getType() +{ + return tnlString( "tnlLinearDiffusion< " ) + + MeshType::getType() + ", " + + ::getType< Real >() + ", " + + ::getType< Index >() + " >"; +} + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > + template< typename Vector > +#ifdef HAVE_CUDA +__device__ __host__ +#endif +void +tnlLinearDiffusion< tnlGrid< 3, MeshReal, Device, MeshIndex >, Real, Index >:: +explicitUpdate( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType cellIndex, + const CoordinatesType& coordinates, + Vector& u, + Vector& fu ) const +{ + fu[ cellIndex ] = ( u[ mesh.getCellXPredecessor( cellIndex ) ] + - 2.0 * u[ cellIndex ] + + u[ mesh.getCellXSuccessor( cellIndex ) ] ) * mesh.getHxSquareInverse() + + ( u[ mesh.getCellYPredecessor( cellIndex ) ] + - 2.0 * u[ cellIndex ] + + u[ mesh.getCellYSuccessor( cellIndex ) ] ) * mesh.getHySquareInverse() + + ( u[ mesh.getCellZPredecessor( cellIndex ) ] + - 2.0 * u[ cellIndex ] + + u[ mesh.getCellZSuccessor( cellIndex ) ] ) * mesh.getHzSquareInverse(); +} + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +template< typename Vector > +#ifdef HAVE_CUDA +__device__ __host__ +#endif +Real +tnlLinearDiffusion< tnlGrid< 3, MeshReal, Device, MeshIndex >, Real, Index >:: +getValue( const MeshType& mesh, + const IndexType cellIndex, + Vector& u ) const +{ + return ( u[ mesh.getCellXPredecessor( cellIndex ) ] + - 2.0 * u[ cellIndex ] + + u[ mesh.getCellXSuccessor( cellIndex ) ] ) * mesh.getHxSquareInverse() + + ( u[ mesh.getCellYPredecessor( cellIndex ) ] + - 2.0 * u[ cellIndex ] + + u[ mesh.getCellYSuccessor( cellIndex ) ] ) * mesh.getHySquareInverse() + + ( u[ mesh.getCellZPredecessor( cellIndex ) ] + - 2.0 * u[ cellIndex ] + + u[ mesh.getCellZSuccessor( cellIndex ) ] ) * mesh.getHzSquareInverse(); +} + + +#endif /* TNLLINEARDIFFUSION_IMP_H */ diff --git a/src/implementation/schemes/euler/CMakeLists.txt b/src/implementation/operators/euler/CMakeLists.txt similarity index 100% rename from src/implementation/schemes/euler/CMakeLists.txt rename to src/implementation/operators/euler/CMakeLists.txt diff --git a/src/implementation/schemes/euler/fvm/CMakeLists.txt b/src/implementation/operators/euler/fvm/CMakeLists.txt similarity index 100% rename from src/implementation/schemes/euler/fvm/CMakeLists.txt rename to src/implementation/operators/euler/fvm/CMakeLists.txt diff --git a/src/implementation/schemes/euler/fvm/tnlLaxFridrichs_impl.h b/src/implementation/operators/euler/fvm/tnlLaxFridrichs_impl.h similarity index 100% rename from src/implementation/schemes/euler/fvm/tnlLaxFridrichs_impl.h rename to src/implementation/operators/euler/fvm/tnlLaxFridrichs_impl.h diff --git a/src/implementation/schemes/gradient/CMakeLists.txt b/src/implementation/operators/gradient/CMakeLists.txt similarity index 100% rename from src/implementation/schemes/gradient/CMakeLists.txt rename to src/implementation/operators/gradient/CMakeLists.txt diff --git a/src/implementation/schemes/gradient/tnlCentralFDMGradient_impl.h b/src/implementation/operators/gradient/tnlCentralFDMGradient_impl.h similarity index 100% rename from src/implementation/schemes/gradient/tnlCentralFDMGradient_impl.h rename to src/implementation/operators/gradient/tnlCentralFDMGradient_impl.h diff --git a/examples/heat-equation/tnlDirichletBoundaryConditions_impl.h b/src/implementation/operators/tnlDirichletBoundaryConditions_impl.h similarity index 93% rename from examples/heat-equation/tnlDirichletBoundaryConditions_impl.h rename to src/implementation/operators/tnlDirichletBoundaryConditions_impl.h index 340f21f89b9a9f1c2ab853923794330095405829..7928fa51764b1f6a86dc5bf8d8f263a4a52524a5 100644 --- a/examples/heat-equation/tnlDirichletBoundaryConditions_impl.h +++ b/src/implementation/operators/tnlDirichletBoundaryConditions_impl.h @@ -12,7 +12,7 @@ bool tnlDirichletBoundaryConditions< tnlGrid< 1,MeshReal, Device, MeshIndex >, Function, Real, Index >:: init( const tnlParameterContainer& parameters ) { - return function.init( parameters ); + return function.init( parameters, "boundary-conditions-" ); } template< typename MeshReal, @@ -32,7 +32,7 @@ setBoundaryConditions( const RealType& time, DofVectorType& fu ) { fu[ index ] = 0; - u[ index ] = function.getValue( mesh.getVertex( coordinates ) ); + u[ index ] = function.getValue( mesh.getVertex( coordinates ), time ); } template< typename MeshReal, @@ -45,7 +45,7 @@ bool tnlDirichletBoundaryConditions< tnlGrid< 2,MeshReal, Device, MeshIndex >, Function, Real, Index >:: init( const tnlParameterContainer& parameters ) { - return function.init( parameters ); + return function.init( parameters, "boundary-conditions-" ); } @@ -66,7 +66,7 @@ setBoundaryConditions( const RealType& time, DofVectorType& fu ) { fu[ index ] = 0; - u[ index ] = function.getValue( mesh.getVertex( coordinates ) );; + u[ index ] = function.getValue( mesh.getVertex( coordinates ), time );; } template< typename MeshReal, @@ -79,7 +79,7 @@ bool tnlDirichletBoundaryConditions< tnlGrid< 3,MeshReal, Device, MeshIndex >, Function, Real, Index >:: init( const tnlParameterContainer& parameters ) { - return function.init( parameters ); + return function.init( parameters, "boundary-conditions-" ); } template< typename MeshReal, @@ -99,7 +99,7 @@ setBoundaryConditions( const RealType& time, DofVectorType& fu ) { fu[ index ] = 0; - u[ index ] = function.getValue( mesh.getVertex( coordinates ) );; + u[ index ] = function.getValue( mesh.getVertex( coordinates ), time );; } diff --git a/src/implementation/schemes/tnlFiniteDifferences_impl.h b/src/implementation/operators/tnlFiniteDifferences_impl.h similarity index 98% rename from src/implementation/schemes/tnlFiniteDifferences_impl.h rename to src/implementation/operators/tnlFiniteDifferences_impl.h index f6badbce6fb1e50a8ed4ab7bd39b99e276cb00c5..513614fa67b0d416f0e16bb4be16f5bbea0c2d4d 100644 --- a/src/implementation/schemes/tnlFiniteDifferences_impl.h +++ b/src/implementation/operators/tnlFiniteDifferences_impl.h @@ -18,7 +18,7 @@ #ifndef TNLFINITEDIFFERENCES_IMPL_H_ #define TNLFINITEDIFFERENCES_IMPL_H_ -#include <schemes/tnlFiniteDifferences.h> +#include <operators/tnlFiniteDifferences.h> template< typename Real, typename Device, typename Index > template< typename GridFunction, @@ -186,7 +186,7 @@ Real tnlFiniteDifferences< tnlGrid< 3, Real, Device, Index > >::getDifference( c } -#include <implementation/schemes/tnlFiniteDifferences_impl.h> +#include <implementation/operators/tnlFiniteDifferences_impl.h> diff --git a/examples/heat-equation/tnlNeumannBoundaryConditions_impl.h b/src/implementation/operators/tnlNeumannBoundaryConditions_impl.h similarity index 98% rename from examples/heat-equation/tnlNeumannBoundaryConditions_impl.h rename to src/implementation/operators/tnlNeumannBoundaryConditions_impl.h index 179e81de817a4e7d620ce8537bb5e23ec0ef74a6..180a42e774b373d589afb196ff1be2fcf2ccddf0 100644 --- a/examples/heat-equation/tnlNeumannBoundaryConditions_impl.h +++ b/src/implementation/operators/tnlNeumannBoundaryConditions_impl.h @@ -1,8 +1,6 @@ #ifndef TNLNEUMANNBOUNDARYCONDITIONS_IMPL_H #define TNLNEUMANNBOUNDARYCONDITIONS_IMPL_H -#include "tnlNeumannBoundaryConditions.h" - template<typename Real, typename Device, typename Index> template<typename AnalyticSpaceFunction, typename TimeFunction, typename Vector> diff --git a/src/implementation/schemes/CMakeLists.txt b/src/implementation/schemes/CMakeLists.txt deleted file mode 100755 index 93f0713d26dbb7bb4a8b1e763cb8501c3dca906e..0000000000000000000000000000000000000000 --- a/src/implementation/schemes/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -ADD_SUBDIRECTORY( gradient ) -ADD_SUBDIRECTORY( diffusion ) -ADD_SUBDIRECTORY( euler ) - -SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/implementation/schemes ) - -if( BUILD_CUDA) - set( tnl_implementation_schemes_CUDA__SOURCES - ${tnl_implementation_schemes_diffusion_CUDA__SOURCES} - ${tnl_implementation_schemes_gradient_CUDA__SOURCES} - ${tnl_implementation_schemes_euler_CUDA__SOURCES} - ${common_SOURCES} - PARENT_SCOPE ) -endif() - -set( tnl_implementation_schemes_SOURCES - ${tnl_implementation_schemes_diffusion_SOURCES} - ${tnl_implementation_schemes_gradient_SOURCES} - ${tnl_implementation_schemes_euler_SOURCES} - ${common_SOURCES} - PARENT_SCOPE ) - -INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/implementation/schemes ) diff --git a/src/implementation/schemes/diffusion/tnlLinearDiffusion_impl.h b/src/implementation/schemes/diffusion/tnlLinearDiffusion_impl.h deleted file mode 100644 index 5aad02312b99a433d0f4eb2e7b9f32f846201c45..0000000000000000000000000000000000000000 --- a/src/implementation/schemes/diffusion/tnlLinearDiffusion_impl.h +++ /dev/null @@ -1,81 +0,0 @@ - -#ifndef TNLLINEARDIFFUSION_IMP_H -#define TNLLINEARDIFFUSION_IMP_H - -#include <schemes/diffusion/tnlLinearDiffusion.h> -#include <mesh/tnlGrid.h> - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > - template< typename Vector > -void -tnlLinearDiffusion< tnlGrid< 1, MeshReal, Device, MeshIndex >, Real, Index >:: -explicitUpdate( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType cellIndex, - const CoordinatesType& coordinates, - Vector& u, - Vector& fu ) -{ - fu[ cellIndex ] = ( u[ mesh.getCellXPredecessor( cellIndex ) ] - - 2.0 * u[ cellIndex ] - + u[ mesh.getCellXSuccessor( cellIndex ) ] ) * mesh.getHxSquareInverse(); -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > - template< typename Vector > -void -tnlLinearDiffusion< tnlGrid< 2, MeshReal, Device, MeshIndex >, Real, Index >:: -explicitUpdate( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType cellIndex, - const CoordinatesType& coordinates, - Vector& u, - Vector& fu ) -{ - fu[ cellIndex ] = ( u[ mesh.getCellXPredecessor( cellIndex ) ] - - 2.0 * u[ cellIndex ] - + u[ mesh.getCellXSuccessor( cellIndex ) ] ) * mesh.getHxSquareInverse() + - ( u[ mesh.getCellYPredecessor( cellIndex ) ] - - 2.0 * u[ cellIndex ] - + u[ mesh.getCellYSuccessor( cellIndex ) ] ) * mesh.getHySquareInverse(); -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > - template< typename Vector > -void -tnlLinearDiffusion< tnlGrid< 3, MeshReal, Device, MeshIndex >, Real, Index >:: -explicitUpdate( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType cellIndex, - const CoordinatesType& coordinates, - Vector& u, - Vector& fu ) -{ - fu[ cellIndex ] = ( u[ mesh.getCellXPredecessor( cellIndex ) ] - - 2.0 * u[ cellIndex ] - + u[ mesh.getCellXSuccessor( cellIndex ) ] ) * mesh.getHxSquareInverse() + - ( u[ mesh.getCellYPredecessor( cellIndex ) ] - - 2.0 * u[ cellIndex ] - + u[ mesh.getCellYSuccessor( cellIndex ) ] ) * mesh.getHySquareInverse() + - ( u[ mesh.getCellZPredecessor( cellIndex ) ] - - 2.0 * u[ cellIndex ] - + u[ mesh.getCellZSuccessor( cellIndex ) ] ) * mesh.getHzSquareInverse(); -} - - -#endif /* TNLLINEARDIFFUSION_IMP_H */ diff --git a/src/implementation/solvers/linear/krylov/tnlTFQMRSolver_impl.h b/src/implementation/solvers/linear/krylov/tnlTFQMRSolver_impl.h index 0ecb2268c342b0d97d97fbfc7cfb791db1bd9ece..a9af14cf01a527a9272808975e7cac6fa07bf893 100644 --- a/src/implementation/solvers/linear/krylov/tnlTFQMRSolver_impl.h +++ b/src/implementation/solvers/linear/krylov/tnlTFQMRSolver_impl.h @@ -37,9 +37,9 @@ template< typename Matrix, tnlString tnlTFQMRSolver< Matrix, Preconditioner > :: getType() const { return tnlString( "tnlTFQMRSolver< " ) + - tnlString( GetParameterType( ( RealType ) 0.0 ) ) + ", " + + tnlString( getType( ( RealType ) 0.0 ) ) + ", " + Device :: getDeviceType() + ", " + - tnlString( GetParameterType( ( IndexType ) 0 ) ) + " >"; + tnlString( getType( ( IndexType ) 0 ) ) + " >"; } template< typename Matrix, diff --git a/src/implementation/solvers/pde/tnlExplicitUpdater_impl.h b/src/implementation/solvers/pde/tnlExplicitUpdater_impl.h index 30ffc12c8d7e31747f6e61c9962296870687cae2..4fb825df84127196bd1c13248166e2b7a820b4fa 100644 --- a/src/implementation/solvers/pde/tnlExplicitUpdater_impl.h +++ b/src/implementation/solvers/pde/tnlExplicitUpdater_impl.h @@ -24,20 +24,22 @@ template< typename Mesh, typename DofVector, + typename DifferentialOperator, typename BoundaryConditions, - typename InteriorUpdater > + typename RightHandSide > template< int EntityDimensions > void -tnlExplicitUpdater< Mesh, DofVector, BoundaryConditions, InteriorUpdater >:: +tnlExplicitUpdater< Mesh, DofVector, DifferentialOperator, BoundaryConditions, RightHandSide >:: update( const RealType& time, const RealType& tau, const Mesh& mesh, + DifferentialOperator& differentialOperator, BoundaryConditions& boundaryConditions, - InteriorUpdater& interiorUpdater, + RightHandSide& rightHandSide, DofVector& u, DofVector& fu ) const { - TraversalUserData userData( time, tau, boundaryConditions, interiorUpdater, u, fu ); + TraversalUserData userData( time, tau, differentialOperator, boundaryConditions, rightHandSide, u, fu ); TraversalBoundaryEntitiesProcessor boundaryEntitiesProcessor; TraversalInteriorEntitiesProcessor interiorEntitiesProcessor; tnlTraversal< MeshType, EntityDimensions > meshTraversal; @@ -55,20 +57,22 @@ template< int Dimensions, typename Device, typename Index, typename DofVector, + typename DifferentialOperator, typename BoundaryConditions, - typename InteriorUpdater > + typename RightHandSide > template< int EntityDimensions > void -tnlExplicitUpdater< tnlGrid< Dimensions, Real, Device, Index >, DofVector, BoundaryConditions, InteriorUpdater >:: +tnlExplicitUpdater< tnlGrid< Dimensions, Real, Device, Index >, DofVector, DifferentialOperator, BoundaryConditions, RightHandSide >:: update( const RealType& time, const RealType& tau, const tnlGrid< Dimensions, Real, Device, Index >& mesh, + DifferentialOperator& differentialOperator, BoundaryConditions& boundaryConditions, - InteriorUpdater& interiorUpdater, + RightHandSide& rightHandSide, DofVector& u, DofVector& fu ) const { - TraversalUserData userData( time, tau, boundaryConditions, interiorUpdater, u, fu ); + TraversalUserData userData( time, tau, differentialOperator, boundaryConditions, rightHandSide, u, fu ); TraversalBoundaryEntitiesProcessor boundaryEntitiesProcessor; TraversalInteriorEntitiesProcessor interiorEntitiesProcessor; tnlTraversal< MeshType, EntityDimensions > meshTraversal; diff --git a/src/implementation/solvers/tnlMeshTypeResolver_impl.h b/src/implementation/solvers/tnlMeshTypeResolver_impl.h index 415f43e210a4f4166fbdda07d6867e6f46427b65..ed320f6b51663490edc4e0ab86bb7308a53171c1 100644 --- a/src/implementation/solvers/tnlMeshTypeResolver_impl.h +++ b/src/implementation/solvers/tnlMeshTypeResolver_impl.h @@ -155,7 +155,7 @@ class tnlMeshResolverTerminator< ProblemSetter, Real, Device, Index, MeshType, C public: static bool run( const tnlParameterContainer& parameters ) { - cerr << "The mesh type " << getParameterType< MeshType >() << " is not supported." << endl; + cerr << "The mesh type " << ::getType< MeshType >() << " is not supported." << endl; return false; }; }; diff --git a/src/legacy/core/tnlTuple.h b/src/legacy/core/tnlTuple.h index 7efabddcac58c64038c5cec9d07ffda87976815d..1ade8c9ba98783dbf4ae727e63747c4a23bfc497 100644 --- a/src/legacy/core/tnlTuple.h +++ b/src/legacy/core/tnlTuple.h @@ -337,7 +337,7 @@ tnlString tnlStaticVector< Size, Real > :: getType() return tnlString( "tnlStaticVector< " ) + tnlString( Size ) + tnlString( ", " ) + - getParameterType< Real >() + + ::getType< Real >() + tnlString( " >" ); } diff --git a/src/legacy/matrices/tnlAdaptiveRgCSRMatrix.h b/src/legacy/matrices/tnlAdaptiveRgCSRMatrix.h index ffb4e2e318d6e4f242c4cd3aeb94240c5f6120cd..d5e02d7712d2c91409d2e0a07ebd8178db9602a0 100644 --- a/src/legacy/matrices/tnlAdaptiveRgCSRMatrix.h +++ b/src/legacy/matrices/tnlAdaptiveRgCSRMatrix.h @@ -45,7 +45,7 @@ struct tnlARGCSRGroupProperties ostream& operator << ( ostream& str, const tnlARGCSRGroupProperties& p ){}; -inline tnlString GetParameterType( const tnlARGCSRGroupProperties& a ) +inline tnlString getType( const tnlARGCSRGroupProperties& a ) { return tnlString( "tnlARGCSRGroupProperties" ); } @@ -226,11 +226,11 @@ template< typename Real, typename Device, typename Index > tnlString tnlAdaptiveRgCSRMatrix< Real, Device, Index > :: getType() const { return tnlString( "tnlAdaptiveRgCSRMatrix< ") + - tnlString( GetParameterType( Real( 0.0 ) ) ) + + tnlString( getType( Real( 0.0 ) ) ) + tnlString( ", " ) + Device :: getDeviceType() + tnlString( ", " ) + - GetParameterType( Index( 0 ) ) + + getType( Index( 0 ) ) + tnlString( " >" ); }; diff --git a/src/legacy/matrices/tnlCSRMatrix.h b/src/legacy/matrices/tnlCSRMatrix.h index 0a01b77984ff9b7d024107b81150415af5044d71..79e531fd0452605b9a5b33f4ac0ca1490703a37a 100644 --- a/src/legacy/matrices/tnlCSRMatrix.h +++ b/src/legacy/matrices/tnlCSRMatrix.h @@ -260,7 +260,7 @@ template< typename Real, typename Device, typename Index > tnlString tnlCSRMatrix< Real, Device, Index > :: getType() const { return tnlString( "tnlCSRMatrix< ") + - tnlString( getParameterType< Real >() ) + + tnlString( ::getType< Real >() ) + tnlString( ", " ) + Device :: getDeviceType() + tnlString( " >" ); diff --git a/src/legacy/matrices/tnlCusparseCSRMatrix.h b/src/legacy/matrices/tnlCusparseCSRMatrix.h index 80b1b4d82fc095fdde8f893bb968b2fe5f47fe2e..c05be19bb41890b52477a493342027d4846bb5d7 100644 --- a/src/legacy/matrices/tnlCusparseCSRMatrix.h +++ b/src/legacy/matrices/tnlCusparseCSRMatrix.h @@ -199,7 +199,7 @@ template< typename Real, typename Device, typename Index > tnlString tnlCusparseCSRMatrix< Real, Device, Index > :: getType() const { return tnlString( "tnlCusparseCSRMatrix< ") + - tnlString( GetParameterType( Real( 0.0 ) ) ) + + tnlString( getType( Real( 0.0 ) ) ) + tnlString( ", " ) + Device :: getDeviceType() + tnlString( " >" ); diff --git a/src/legacy/matrices/tnlEllpackMatrix.h b/src/legacy/matrices/tnlEllpackMatrix.h index 2c357f508c81c22917cf38669308f01512f74a36..16146ec3f27626954a1b39e2f68b0ff716670075 100644 --- a/src/legacy/matrices/tnlEllpackMatrix.h +++ b/src/legacy/matrices/tnlEllpackMatrix.h @@ -126,7 +126,7 @@ const tnlString& tnlEllpackMatrix< Real, tnlHost, Index > :: getMatrixClass() co template< typename Real, typename Index > tnlString tnlEllpackMatrix< Real, tnlHost, Index > :: getType() const { - return tnlString( "tnlEllpackMatrix< ") + tnlString( GetParameterType( Real( 0.0 ) ) ) + tnlString( ", tnlHost >" ); + return tnlString( "tnlEllpackMatrix< ") + tnlString( getType( Real( 0.0 ) ) ) + tnlString( ", tnlHost >" ); }; template< typename Real, typename Index > diff --git a/src/legacy/matrices/tnlEllpackMatrixCUDA.h b/src/legacy/matrices/tnlEllpackMatrixCUDA.h index 33129ccf67fe7e92507fa76969e43b8abdf2f3b7..07e9216076197f614558e1b696ff4a1a537f61ce 100644 --- a/src/legacy/matrices/tnlEllpackMatrixCUDA.h +++ b/src/legacy/matrices/tnlEllpackMatrixCUDA.h @@ -160,7 +160,7 @@ const tnlString& tnlEllpackMatrix< Real, tnlCuda, Index > :: getMatrixClass() co template< typename Real, typename Index > tnlString tnlEllpackMatrix< Real, tnlCuda, Index > :: getType() const { - return tnlString( "tnlEllpackMatrix< ") + tnlString( GetParameterType( Real( 0.0 ) ) ) + tnlString( ", tnlCuda >" ); + return tnlString( "tnlEllpackMatrix< ") + tnlString( getType( Real( 0.0 ) ) ) + tnlString( ", tnlCuda >" ); }; template< typename Real, typename Index > diff --git a/src/legacy/matrices/tnlFastCSRMatrix.h b/src/legacy/matrices/tnlFastCSRMatrix.h index f232c01c4b63c08cbeb0507c761c0236762f1337..b00df4b26605550ad2a9a8ca4468e0ca01fab0ab 100644 --- a/src/legacy/matrices/tnlFastCSRMatrix.h +++ b/src/legacy/matrices/tnlFastCSRMatrix.h @@ -197,7 +197,7 @@ const tnlString& tnlFastCSRMatrix< Real, tnlHost, Index > :: getMatrixClass() co template< typename Real, typename Index > tnlString tnlFastCSRMatrix< Real, tnlHost, Index > :: getType() const { - return tnlString( "tnlFastCSRMatrix< ") + tnlString( GetParameterType( Real( 0.0 ) ) ) + tnlString( ", tnlHost >" ); + return tnlString( "tnlFastCSRMatrix< ") + tnlString( getType( Real( 0.0 ) ) ) + tnlString( ", tnlHost >" ); }; template< typename Real, typename Index > diff --git a/src/legacy/matrices/tnlFastRgCSRMatrix.h b/src/legacy/matrices/tnlFastRgCSRMatrix.h index dc506ac8f09e23919a22dd38fd12896c98c3027b..b5003985bd45645aadd720f8219300d9f05d5812 100644 --- a/src/legacy/matrices/tnlFastRgCSRMatrix.h +++ b/src/legacy/matrices/tnlFastRgCSRMatrix.h @@ -177,7 +177,7 @@ const tnlString& tnlFastRgCSRMatrix< Real, tnlHost, Index > :: getMatrixClass() template< typename Real, typename Index > tnlString tnlFastRgCSRMatrix< Real, tnlHost, Index > :: getType() const { - return tnlString( "tnlFastRgCSRMatrix< ") + tnlString( GetParameterType( Real( 0.0 ) ) ) + tnlString( ", tnlHost >" ); + return tnlString( "tnlFastRgCSRMatrix< ") + tnlString( getType( Real( 0.0 ) ) ) + tnlString( ", tnlHost >" ); }; template< typename Real, typename Index > diff --git a/src/legacy/matrices/tnlFastRgCSRMatrixCUDA.h b/src/legacy/matrices/tnlFastRgCSRMatrixCUDA.h index 350e4a6e252cc74d03a1f4002931ca9ac86e44c1..ba7ef95556c177f0077d860d1ed75a0f3bb4bea7 100644 --- a/src/legacy/matrices/tnlFastRgCSRMatrixCUDA.h +++ b/src/legacy/matrices/tnlFastRgCSRMatrixCUDA.h @@ -195,7 +195,7 @@ const tnlString& tnlFastRgCSRMatrix< Real, tnlCuda, Index > :: getMatrixClass() template< typename Real, typename Index > tnlString tnlFastRgCSRMatrix< Real, tnlCuda, Index > :: getType() const { - return tnlString( "tnlFastRgCSRMatrix< ") + tnlString( GetParameterType( Real( 0.0 ) ) ) + tnlString( ", tnlCuda >" ); + return tnlString( "tnlFastRgCSRMatrix< ") + tnlString( getType( Real( 0.0 ) ) ) + tnlString( ", tnlCuda >" ); }; template< typename Real, typename Index > diff --git a/src/legacy/matrices/tnlFullMatrix.h b/src/legacy/matrices/tnlFullMatrix.h index 57bad8c421d2915df2730211d3151a2d4d311532..a9a230314b4d445c6bf3759a47af79c140561d1e 100644 --- a/src/legacy/matrices/tnlFullMatrix.h +++ b/src/legacy/matrices/tnlFullMatrix.h @@ -97,7 +97,7 @@ template< typename Real, typename Device, typename Index > tnlString tnlFullMatrix< Real, Device, Index > :: getType() const { Real t; - return tnlString( "tnlFullMatrix< " ) + tnlString( GetParameterType( t ) ) + tnlString( " >" ); + return tnlString( "tnlFullMatrix< " ) + tnlString( getType( t ) ) + tnlString( " >" ); }; template< typename Real, typename Device, typename Index > diff --git a/src/legacy/matrices/tnlPETSCMatrix.h b/src/legacy/matrices/tnlPETSCMatrix.h index 22ab9c594ced140db01eb4ce2a3b688b36f3dd0b..c8db5705ea50489689709582395cdf7416155d4a 100644 --- a/src/legacy/matrices/tnlPETSCMatrix.h +++ b/src/legacy/matrices/tnlPETSCMatrix.h @@ -59,7 +59,7 @@ template< typename T > class tnlPETSCMatrix : public tnlMatrix< T > tnlString getType() const { T t; - return tnlString( "tnlPETSCMatrix< " ) + tnlString( GetParameterType( t ) ) + tnlString( " >" ); + return tnlString( "tnlPETSCMatrix< " ) + tnlString( getType( t ) ) + tnlString( " >" ); }; const tnlString& getMatrixClass() const diff --git a/src/legacy/matrices/tnlRgCSRMatrix.h b/src/legacy/matrices/tnlRgCSRMatrix.h index 971f9d987351eb28dea7d8c096eb1f038557e583..df7216035e61d000b2a19c2c5312f6fc15cd7bfb 100644 --- a/src/legacy/matrices/tnlRgCSRMatrix.h +++ b/src/legacy/matrices/tnlRgCSRMatrix.h @@ -256,11 +256,11 @@ template< typename Real, typename Device, typename Index > tnlString tnlRgCSRMatrix< Real, Device, Index > :: getType() const { return tnlString( "tnlRgCSRMatrix< ") + - tnlString( GetParameterType( Real( 0.0 ) ) ) + + tnlString( getType( Real( 0.0 ) ) ) + tnlString( ", " ) + Device :: getDeviceType() + tnlString( ", " ) + - GetParameterType( Index( 0 ) ) + + getType( Index( 0 ) ) + tnlString( " >" ); // TODO: add value of useAdaptiveGroupSize }; diff --git a/src/legacy/mesh/implementation/tnlGrid1D_impl.h b/src/legacy/mesh/implementation/tnlGrid1D_impl.h index 1a9abf084370101db0e8926a725a84421444b28f..e61c4122e86ad9ff509e19cc766f28e15943ec17 100644 --- a/src/legacy/mesh/implementation/tnlGrid1D_impl.h +++ b/src/legacy/mesh/implementation/tnlGrid1D_impl.h @@ -133,11 +133,11 @@ tnlString tnlGridOld< 1, Real, Device, Index > :: getType() const return tnlString( "tnlGridOld< ") + tnlString( "1" ) + tnlString( ", " ) + - tnlString( getParameterType< Real >() ) + + tnlString( ::getType< Real >() ) + tnlString( ", " ) + Device :: getDeviceType() + tnlString( ", " ) + - tnlString( getParameterType< Index >() ) + + tnlString( ::getType< Index >() ) + tnlString( " >" ); } diff --git a/src/legacy/mesh/implementation/tnlGrid2D_impl.h b/src/legacy/mesh/implementation/tnlGrid2D_impl.h index ba40715866157ee833f35a8995f0fbfd08f150c1..2a6d9a668588c62c9133feec4a89b6c3f2d0f032 100644 --- a/src/legacy/mesh/implementation/tnlGrid2D_impl.h +++ b/src/legacy/mesh/implementation/tnlGrid2D_impl.h @@ -140,11 +140,11 @@ tnlString tnlGridOld< 2, Real, Device, Index > :: getType() const return tnlString( "tnlGridOld< ") + tnlString( "2" ) + tnlString( ", " ) + - tnlString( getParameterType< Real >() ) + + tnlString( ::getType< Real >() ) + tnlString( ", " ) + Device :: getDeviceType() + tnlString( ", " ) + - tnlString( getParameterType< Index >() ) + + tnlString( ::getType< Index >() ) + tnlString( " >" ); } diff --git a/src/legacy/mesh/implementation/tnlGrid3D_impl.h b/src/legacy/mesh/implementation/tnlGrid3D_impl.h index d9d9aad7e68c1cfa7d580bbf27b8d5831dddecb0..e3d7757e7bb2b97a13eb97a8bfb4de6470d99515 100644 --- a/src/legacy/mesh/implementation/tnlGrid3D_impl.h +++ b/src/legacy/mesh/implementation/tnlGrid3D_impl.h @@ -143,11 +143,11 @@ tnlString tnlGridOld< 3,Real, Device, Index > :: getType() const return tnlString( "tnlGridOld< ") + tnlString( "3" ) + tnlString( ", " ) + - tnlString( getParameterType< Real >() ) + + tnlString( ::getType< Real >() ) + tnlString( ", " ) + Device :: getDeviceType() + tnlString( ", " ) + - tnlString( getParameterType< Index >() ) + + tnlString( ::getType< Index >() ) + tnlString( " >" ); } diff --git a/src/legacy/schemes/tnlLinearDiffusion.h b/src/legacy/schemes/tnlLinearDiffusion.h index 4ad576624c44ea2b236fc8ef169a039e0c44099b..fbf51629e3aa73c830952d549835504d84a5495a 100644 --- a/src/legacy/schemes/tnlLinearDiffusion.h +++ b/src/legacy/schemes/tnlLinearDiffusion.h @@ -100,6 +100,6 @@ class tnlLinearDiffusion< tnlGrid< 2, Real, Device, Index, tnlIdenticalGridGeome }; -#include <implementation/schemes/diffusion/tnlLinearDiffusion_impl.h> +#include <implementation/operators/diffusion/tnlLinearDiffusion_impl.h> #endif diff --git a/src/legacy/solvers/tnlGMRESSolverOld.h b/src/legacy/solvers/tnlGMRESSolverOld.h index 58e38dcb62596c22b98d44d0f3a23e03686593d2..41a8ec4bca5b34d798342d6352789fb1e17757a4 100644 --- a/src/legacy/solvers/tnlGMRESSolverOld.h +++ b/src/legacy/solvers/tnlGMRESSolverOld.h @@ -95,11 +95,11 @@ template< typename Real, typename Device, typename Index > tnlString tnlGMRESSolverOld< Real, Device, Index > :: getType() const { return tnlString( "tnlGMRESSolverOld< " ) + - tnlString( GetParameterType( ( Real ) 0.0 ) ) + + tnlString( getType( ( Real ) 0.0 ) ) + tnlString( ", " ) + Device :: getDeviceType() + tnlString( ", " ) + - tnlString( GetParameterType( ( Index ) 0 ) ) + + tnlString( getType( ( Index ) 0 ) ) + tnlString( " >" ); } diff --git a/src/legacy/solvers/tnlILUPreconditioner.h b/src/legacy/solvers/tnlILUPreconditioner.h index ada8fc364575763835aa31872f6a3b2d82447610..1053b2a7eb233c50ba3aac1cab7898a98b2fafb6 100644 --- a/src/legacy/solvers/tnlILUPreconditioner.h +++ b/src/legacy/solvers/tnlILUPreconditioner.h @@ -44,7 +44,7 @@ template< typename T > class tnlILUPreconditioner : public tnlPreconditioner< T tnlString getType() const { T t; - return tnlString( "tnlILUPreconditioner< " ) + tnlString( GetParameterType( t ) ) + tnlString( " >" ); + return tnlString( "tnlILUPreconditioner< " ) + tnlString( getType( t ) ) + tnlString( " >" ); }; diff --git a/src/legacy/solvers/tnlSORSolver.h b/src/legacy/solvers/tnlSORSolver.h index 7d6c50ab0f93e4b20bd92cddb8ebe94cff4550be..a184311b11ce7e0fdeb1d17683299514ca29c3c2 100644 --- a/src/legacy/solvers/tnlSORSolver.h +++ b/src/legacy/solvers/tnlSORSolver.h @@ -58,11 +58,11 @@ template< typename Real, typename Device, typename Index > tnlString tnlSORSolverOld< Real, Device, Index > :: getType() const { return tnlString( "tnlSORSolverOld< " ) + - tnlString( GetParameterType( ( Real ) 0.0 ) ) + + tnlString( getType( ( Real ) 0.0 ) ) + tnlString( ", " ) + Device :: getDeviceType() + tnlString( ", " ) + - tnlString( GetParameterType( ( Index ) 0 ) ) + + tnlString( getType( ( Index ) 0 ) ) + tnlString( " >" ); } diff --git a/src/mesh/tnlGrid.h b/src/mesh/tnlGrid.h index b6de81e6473d33fa8945ef3541afd9e606f3f467..a01dbec00687f0f830c30181abe98ba741b225b7 100644 --- a/src/mesh/tnlGrid.h +++ b/src/mesh/tnlGrid.h @@ -138,6 +138,12 @@ class tnlGrid< 1, Real, Device, Index > : public tnlObject #endif Vertex getCellCenter( const CoordinatesType& cellCoordinates ) const; + template< typename Vertex = VertexType > +#ifdef HAVE_CUDA + __device__ __host__ +#endif + Vertex getCellCenter( const IndexType& cellIndex ) const; + template< typename Vertex = VertexType > #ifdef HAVE_CUDA __device__ __host__ @@ -159,6 +165,11 @@ class tnlGrid< 1, Real, Device, Index > : public tnlObject #endif bool isBoundaryCell( const CoordinatesType& cellCoordinates ) const; +#ifdef HAVE_CUDA + __device__ __host__ +#endif + bool isBoundaryCell( const IndexType& cellIndex ) const; + #ifdef HAVE_CUDA __device__ __host__ #endif @@ -363,6 +374,12 @@ class tnlGrid< 2, Real, Device, Index > : public tnlObject #endif Vertex getCellCenter( const CoordinatesType& cellCoordinates ) const; + template< typename Vertex = VertexType > +#ifdef HAVE_CUDA + __device__ __host__ +#endif + Vertex getCellCenter( const IndexType& cellIndex ) const; + template< int nx, int ny, typename Vertex = VertexType > #ifdef HAVE_CUDA __device__ __host__ @@ -395,6 +412,11 @@ template< int nx, int ny, typename Vertex = VertexType > #endif bool isBoundaryCell( const CoordinatesType& cellCoordinates ) const; +#ifdef HAVE_CUDA + __device__ __host__ +#endif + bool isBoundaryCell( const IndexType& cellIndex ) const; + template< int nx, int ny > #ifdef HAVE_CUDA __device__ __host__ @@ -674,6 +696,12 @@ class tnlGrid< 3, Real, Device, Index > : public tnlObject #endif Vertex getCellCenter( const CoordinatesType& cellCoordinates ) const; + template< typename Vertex = VertexType > +#ifdef HAVE_CUDA + __device__ __host__ +#endif + Vertex getCellCenter( const IndexType& cellIndex ) const; + template< int nx, int ny, int nz, typename Vertex = VertexType > #ifdef HAVE_CUDA __device__ __host__ @@ -717,6 +745,11 @@ template< int dx, int dy, int dz, typename Vertex = VertexType > #endif bool isBoundaryCell( const CoordinatesType& cellCoordinates ) const; +#ifdef HAVE_CUDA + __device__ __host__ +#endif + bool isBoundaryCell( const IndexType& cellIndex ) const; + template< int nx, int ny, int nz > #ifdef HAVE_CUDA __device__ __host__ diff --git a/src/schemes/CMakeLists.txt b/src/operators/CMakeLists.txt similarity index 77% rename from src/schemes/CMakeLists.txt rename to src/operators/CMakeLists.txt index 492166e63c863c72cb9e6c75872eb80a8414cc25..4312dd8fa72fd14ebb498ec4dbc5895d9c464508 100755 --- a/src/schemes/CMakeLists.txt +++ b/src/operators/CMakeLists.txt @@ -4,7 +4,7 @@ ADD_SUBDIRECTORY( euler ) SET( headers tnlFiniteDifferences.h ) -#SET( libtnlmeshincludedir ${TNL_INCLUDE_DIR}/schemes ) +#SET( libtnlmeshincludedir ${TNL_INCLUDE_DIR}/operators ) #SET( libtnlmeshinclude_HEADERS ${headers} ) -INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/schemes ) \ No newline at end of file +INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/operators ) \ No newline at end of file diff --git a/src/schemes/diffusion/CMakeLists.txt b/src/operators/diffusion/CMakeLists.txt similarity index 100% rename from src/schemes/diffusion/CMakeLists.txt rename to src/operators/diffusion/CMakeLists.txt diff --git a/src/operators/diffusion/tnlExactLinearDiffusion.h b/src/operators/diffusion/tnlExactLinearDiffusion.h new file mode 100644 index 0000000000000000000000000000000000000000..13df353d87a032aaa5f179611a7f1fc1701251a0 --- /dev/null +++ b/src/operators/diffusion/tnlExactLinearDiffusion.h @@ -0,0 +1,72 @@ +/*************************************************************************** + tnlExactLinearDiffusion.h - description + ------------------- + begin : Aug 8, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TNLEXACTLINEARDIFFUSION_H_ +#define TNLEXACTLINEARDIFFUSION_H_ + +template< int Dimensions > +class tnlExactLinearDiffusion +{}; + +template<> +class tnlExactLinearDiffusion< 1 > +{ + public: + + enum { Dimensions = 1 }; + + static tnlString getType(); + + template< typename Function, typename Vertex, typename Real = typename Vertex::RealType > + static Real getValue( const Function& function, + const Vertex& v, + const Real& time = 0.0 ); +}; + +template<> +class tnlExactLinearDiffusion< 2 > +{ + public: + + enum { Dimensions = 2 }; + + static tnlString getType(); + + template< typename Function, typename Vertex, typename Real = typename Vertex::RealType > + static Real getValue( const Function& function, + const Vertex& v, + const Real& time = 0.0 ); +}; + +template<> +class tnlExactLinearDiffusion< 3 > +{ + public: + + enum { Dimensions = 3 }; + + static tnlString getType(); + + template< typename Function, typename Vertex, typename Real = typename Vertex::RealType > + static Real getValue( const Function& function, + const Vertex& v, + const Real& time = 0.0 ); +}; + +#include <implementation/operators/diffusion/tnlExactLinearDiffusion_impl.h> + +#endif /* TNLEXACTLINEARDIFFUSION_H_ */ diff --git a/src/schemes/diffusion/tnlLinearDiffusion.h b/src/operators/diffusion/tnlLinearDiffusion.h similarity index 74% rename from src/schemes/diffusion/tnlLinearDiffusion.h rename to src/operators/diffusion/tnlLinearDiffusion.h index 580bf8ffe20fa04a7b4e2639f8f07455e0cd222c..5cff39f120e88ec0b138174f6686714d9a4b9cbc 100644 --- a/src/schemes/diffusion/tnlLinearDiffusion.h +++ b/src/operators/diffusion/tnlLinearDiffusion.h @@ -2,6 +2,7 @@ #define TNLLINEARDIFFUSION_H #include <core/vectors/tnlVector.h> +#include <mesh/tnlGrid.h> template< typename Mesh, typename Real,// = typename Mesh::RealType, @@ -27,6 +28,8 @@ class tnlLinearDiffusion< tnlGrid< 1,MeshReal, Device, MeshIndex >, Real, Index typedef Device DeviceType; typedef Index IndexType; + static tnlString getType(); + template< typename Vector > #ifdef HAVE_CUDA __device__ __host__ @@ -37,8 +40,16 @@ class tnlLinearDiffusion< tnlGrid< 1,MeshReal, Device, MeshIndex >, Real, Index const IndexType cellIndex, const CoordinatesType& coordinates, Vector& u, - Vector& fu ); + Vector& fu ) const; + template< typename Vector > +#ifdef HAVE_CUDA + __device__ __host__ +#endif + Real getValue( const MeshType& mesh, + const IndexType cellIndex, + Vector& u ) const; + }; @@ -57,6 +68,8 @@ class tnlLinearDiffusion< tnlGrid< 2, MeshReal, Device, MeshIndex >, Real, Index typedef Device DeviceType; typedef Index IndexType; + static tnlString getType(); + template< typename Vector > #ifdef HAVE_CUDA __device__ __host__ @@ -67,8 +80,16 @@ class tnlLinearDiffusion< tnlGrid< 2, MeshReal, Device, MeshIndex >, Real, Index const IndexType index, const CoordinatesType& coordinates, Vector& u, - Vector& fu ); + Vector& fu ) const; + template< typename Vector > +#ifdef HAVE_CUDA + __device__ __host__ +#endif + Real getValue( const MeshType& mesh, + const IndexType cellIndex, + Vector& u ) const; + }; @@ -87,6 +108,8 @@ class tnlLinearDiffusion< tnlGrid< 3, MeshReal, Device, MeshIndex >, Real, Index typedef Device DeviceType; typedef Index IndexType; + static tnlString getType(); + template< typename Vector > #ifdef HAVE_CUDA __device__ __host__ @@ -97,12 +120,20 @@ class tnlLinearDiffusion< tnlGrid< 3, MeshReal, Device, MeshIndex >, Real, Index const IndexType index, const CoordinatesType& coordinates, Vector& u, - Vector& fu ); + Vector& fu ) const; + template< typename Vector > +#ifdef HAVE_CUDA + __device__ __host__ +#endif + Real getValue( const MeshType& mesh, + const IndexType cellIndex, + Vector& u ) const; + }; -#include <implementation/schemes/diffusion/tnlLinearDiffusion_impl.h> +#include <implementation/operators/diffusion/tnlLinearDiffusion_impl.h> #endif /* TNLLINEARDIFFUSION_H */ diff --git a/src/schemes/euler/CMakeLists.txt b/src/operators/euler/CMakeLists.txt similarity index 100% rename from src/schemes/euler/CMakeLists.txt rename to src/operators/euler/CMakeLists.txt diff --git a/src/schemes/euler/fvm/CMakeLists.txt b/src/operators/euler/fvm/CMakeLists.txt similarity index 100% rename from src/schemes/euler/fvm/CMakeLists.txt rename to src/operators/euler/fvm/CMakeLists.txt diff --git a/src/schemes/euler/fvm/tnlLaxFridrichs.h b/src/operators/euler/fvm/tnlLaxFridrichs.h similarity index 97% rename from src/schemes/euler/fvm/tnlLaxFridrichs.h rename to src/operators/euler/fvm/tnlLaxFridrichs.h index 5ada2ca48fcbc5ca13216abe7b29259849ac8fd2..c361c8278397426fe726a9123f768c126bf20354 100644 --- a/src/schemes/euler/fvm/tnlLaxFridrichs.h +++ b/src/operators/euler/fvm/tnlLaxFridrichs.h @@ -21,7 +21,7 @@ #include <core/vectors/tnlSharedVector.h> #include <mesh/tnlGrid.h> #include <mesh/tnlIdenticalGridGeometry.h> -#include <schemes/gradient/tnlCentralFDMGradient.h> +#include <operators/gradient/tnlCentralFDMGradient.h> template< typename Mesh, typename PressureGradient = tnlCentralFDMGradient< Mesh > > @@ -168,6 +168,6 @@ class tnlLaxFridrichs< tnlGrid< 2, Real, Device, Index, tnlIdenticalGridGeometry tnlSharedVector< RealType, DeviceType, IndexType > rho, rho_u1, rho_u2, energy, p; }; -#include <implementation/schemes/euler/fvm/tnlLaxFridrichs_impl.h> +#include <implementation/operators/euler/fvm/tnlLaxFridrichs_impl.h> #endif diff --git a/src/schemes/gradient/CMakeLists.txt b/src/operators/gradient/CMakeLists.txt similarity index 100% rename from src/schemes/gradient/CMakeLists.txt rename to src/operators/gradient/CMakeLists.txt diff --git a/src/schemes/gradient/tnlCentralFDMGradient.h b/src/operators/gradient/tnlCentralFDMGradient.h similarity index 97% rename from src/schemes/gradient/tnlCentralFDMGradient.h rename to src/operators/gradient/tnlCentralFDMGradient.h index b88d455ecfb067d415f86aed64181d8a2594e98d..754afb3b0cb4bee5e237a02f4c549ce33cfe1cf8 100644 --- a/src/schemes/gradient/tnlCentralFDMGradient.h +++ b/src/operators/gradient/tnlCentralFDMGradient.h @@ -91,6 +91,6 @@ class tnlCentralFDMGradient< tnlGrid< 2, Real, Device, Index, tnlIdenticalGridGe }; -#include <implementation/schemes/gradient/tnlCentralFDMGradient_impl.h> +#include <implementation/operators/gradient/tnlCentralFDMGradient_impl.h> #endif diff --git a/examples/heat-equation/tnlDirichletBoundaryConditions.h b/src/operators/tnlDirichletBoundaryConditions.h similarity index 98% rename from examples/heat-equation/tnlDirichletBoundaryConditions.h rename to src/operators/tnlDirichletBoundaryConditions.h index ba9861555d4ddf2a989cd88b2675968c6acc2128..e06b56ed9393e3039dc9fec5086b654b312fe79c 100644 --- a/examples/heat-equation/tnlDirichletBoundaryConditions.h +++ b/src/operators/tnlDirichletBoundaryConditions.h @@ -121,6 +121,6 @@ class tnlDirichletBoundaryConditions< tnlGrid< 3, MeshReal, Device, MeshIndex >, Function function; }; -#include "tnlDirichletBoundaryConditions_impl.h" +#include <implementation/operators/tnlDirichletBoundaryConditions_impl.h> #endif /* TNLDIRICHLETBOUNDARYCONDITIONS_H */ diff --git a/src/schemes/tnlFiniteDifferences.h b/src/operators/tnlFiniteDifferences.h similarity index 99% rename from src/schemes/tnlFiniteDifferences.h rename to src/operators/tnlFiniteDifferences.h index 55f3e577038f39a915ca63fa6bf94b3f0f4e2c47..7437f09e36aa46db0cd8c68bbe156923c7aebb33 100644 --- a/src/schemes/tnlFiniteDifferences.h +++ b/src/operators/tnlFiniteDifferences.h @@ -209,7 +209,7 @@ class tnlFiniteDifferences< tnlGrid< 3, Real, Device, Index > > }; -#include <implementation/schemes/tnlFiniteDifferences_impl.h> +#include <implementation/operators/tnlFiniteDifferences_impl.h> diff --git a/examples/heat-equation/tnlNeumannBoundaryConditions.h b/src/operators/tnlNeumannBoundaryConditions.h similarity index 97% rename from examples/heat-equation/tnlNeumannBoundaryConditions.h rename to src/operators/tnlNeumannBoundaryConditions.h index 1574258a5eb12dd9f74b050ed27fe2b312700dcb..82cf8115910fc0af61e3337a7952fa8653a01429 100644 --- a/examples/heat-equation/tnlNeumannBoundaryConditions.h +++ b/src/operators/tnlNeumannBoundaryConditions.h @@ -79,7 +79,7 @@ class tnlNeumannBoundaryConditions<tnlGrid<3,Real,Device,Index>> AnalyticSpaceFunction& analyticSpaceFunction); }; -#include "tnlNeumannBoundaryConditions_impl.h" +#include <implementation/operators/tnlNeumannBoundaryConditions_impl.h> #endif /* TNLNEUMANNBOUNDARYCONDITIONS_H */ diff --git a/src/solvers/ode/tnlExplicitSolver.h b/src/solvers/ode/tnlExplicitSolver.h index 3525a88f145b8ad74736cd335f74bfb06739236d..1bc63d5ac993508685907856405d2b9cb03c1c92 100644 --- a/src/solvers/ode/tnlExplicitSolver.h +++ b/src/solvers/ode/tnlExplicitSolver.h @@ -120,7 +120,7 @@ tnlExplicitSolver < Problem > :: tnlExplicitSolver() solver_comm( MPI_COMM_WORLD ), verbosity( 0 ), cpu_timer( &default_mcore_cpu_timer ), - rt_timer( &default_mcore_rt_timer ), + rt_timer( &defaultRTTimer ), testingMode( false ), problem( 0 ), solverMonitor( 0 ) diff --git a/src/solvers/pde/tnlExplicitUpdater.h b/src/solvers/pde/tnlExplicitUpdater.h index fde11e326a1965184cc14bc1919647d4a0a85559..c156a702d4443ffd80ea05c4a7f9f69a1802cb60 100644 --- a/src/solvers/pde/tnlExplicitUpdater.h +++ b/src/solvers/pde/tnlExplicitUpdater.h @@ -20,38 +20,50 @@ template< typename Real, typename DofVector, + typename DifferentialOperator, typename BoundaryConditions, - typename InteriorUpdater > + typename RightHandSide > class tnlExplicitUpdaterTraversalUserData { public: + const Real &time, τ + DifferentialOperator& differentialOperator; + BoundaryConditions& boundaryConditions; - InteriorUpdater& interiorUpdater; + RightHandSide& rightHandSide; DofVector &u, &fu; tnlExplicitUpdaterTraversalUserData( const Real& time, const Real& tau, + DifferentialOperator& differentialOperator, BoundaryConditions& boundaryConditions, - InteriorUpdater& interiorUpdater, + RightHandSide& rightHandSide, DofVector& u, DofVector& fu ) : time( time ), tau( tau ), + differentialOperator( differentialOperator ), boundaryConditions( boundaryConditions ), - interiorUpdater( interiorUpdater ), + rightHandSide( rightHandSide ), u( u ), fu( fu ) {}; + + protected: + + + }; template< typename Mesh, typename DofVector, + typename DifferentialOperator, typename BoundaryConditions, - typename InteriorUpdater > + typename RightHandSide > class tnlExplicitUpdater { public: @@ -61,15 +73,17 @@ class tnlExplicitUpdater typedef typename DofVector::IndexType IndexType; typedef tnlExplicitUpdaterTraversalUserData< RealType, DofVector, + DifferentialOperator, BoundaryConditions, - InteriorUpdater > TraversalUserData; + RightHandSide > TraversalUserData; template< int EntityDimensions > void update( const RealType& time, const RealType& tau, const MeshType& mesh, + DifferentialOperator& differentialOperator, BoundaryConditions& boundaryConditions, - InteriorUpdater& interiorUpdater, + RightHandSide& rightHandSide, DofVector& u, DofVector& fu ) const; @@ -96,17 +110,19 @@ class tnlExplicitUpdater { public: - template< int EntityDimension > + template< int EntityDimensions > void processEntity( const MeshType& mesh, TraversalUserData& userData, const IndexType index ) { - userData.boundaryConditions.update( userData.time, - userData.tau, - mesh, - index, - userData.u, - userData.fu ); + userData.differentialOperator.update( userData.time, + userData.tau, + mesh, + index, + userData.u, + userData.fu ); + userData.fu[ index ] += userData.rightHandSide.getValue( mesh.getEntityCenter< EntityDimensions >( index ), + userData.time ); } }; @@ -118,12 +134,14 @@ template< int Dimensions, typename Device, typename Index, typename DofVector, + typename DifferentialOperator, typename BoundaryConditions, - typename InteriorUpdater > + typename RightHandSide > class tnlExplicitUpdater< tnlGrid< Dimensions, Real, Device, Index >, DofVector, + DifferentialOperator, BoundaryConditions, - InteriorUpdater > + RightHandSide > { public: @@ -134,15 +152,17 @@ class tnlExplicitUpdater< tnlGrid< Dimensions, Real, Device, Index >, typedef typename MeshType::CoordinatesType CoordinatesType; typedef tnlExplicitUpdaterTraversalUserData< RealType, DofVector, + DifferentialOperator, BoundaryConditions, - InteriorUpdater > TraversalUserData; + RightHandSide > TraversalUserData; template< int EntityDimensions > void update( const RealType& time, const RealType& tau, const MeshType& mesh, + DifferentialOperator& differentialOperator, BoundaryConditions& boundaryConditions, - InteriorUpdater& interiorUpdater, + RightHandSide& rightHandSide, DofVector& u, DofVector& fu ) const; @@ -150,6 +170,10 @@ class tnlExplicitUpdater< tnlGrid< Dimensions, Real, Device, Index >, { public: + /**** + * TODO: This must be specialized for entities with different dimensions + * otherwise 'coordinates' would not make sense without knowing the orientation. + */ template< int EntityDimension > void processEntity( const MeshType& mesh, TraversalUserData& userData, @@ -171,19 +195,22 @@ class tnlExplicitUpdater< tnlGrid< Dimensions, Real, Device, Index >, { public: - template< int EntityDimension > + template< int EntityDimensions > void processEntity( const MeshType& mesh, TraversalUserData& userData, const IndexType index, const CoordinatesType& coordinates ) { - userData.interiorUpdater.explicitUpdate( userData.time, - userData.tau, - mesh, - index, - coordinates, - userData.u, - userData.fu ); + userData.differentialOperator.explicitUpdate( userData.time, + userData.tau, + mesh, + index, + coordinates, + userData.u, + userData.fu ); + + userData.fu[ index ] += userData.rightHandSide.getValue( mesh.getCellCenter( coordinates ), + userData.time ); } }; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2faf4c8966b68ddb94975317b081406b2052b8b9..6282468632b6b7270d46c26ce54a854dfcb9b57a 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,7 +2,6 @@ set( ENABLE_CODECOVERAGE ) ADD_SUBDIRECTORY( data ) ADD_SUBDIRECTORY( benchmarks ) -ADD_SUBDIRECTORY( approximation-tests ) ADD_SUBDIRECTORY( unit-tests ) ADD_SUBDIRECTORY( long-time-unit-tests ) diff --git a/tests/approximation-tests/CMakeLists.txt b/tests/approximation-tests/CMakeLists.txt deleted file mode 100755 index 2dbab42038a25ca50315871c821a1c728ca84553..0000000000000000000000000000000000000000 --- a/tests/approximation-tests/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -INSTALL( FILES tnl-functions-test - DESTINATION share/tnl-${tnlVersion} ) - diff --git a/tests/approximation-tests/tnl-functions-test b/tests/approximation-tests/tnl-functions-test deleted file mode 100644 index 6fa88ae2bf6883f81ef51b5e01aca29cd2eb4b30..0000000000000000000000000000000000000000 --- a/tests/approximation-tests/tnl-functions-test +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -FUNCTIONS="sin-wave" -GRID_DIMS="16 32 64 128 256 512" -for function in $FUNCTIONS; -do - mkdir ${function} - cd ${function} - - for grid_dim in $GRID_DIMS; - do - mkdir ${grid_dim} - cd ${grid_dim} - - tnl-grid-setup --output-file mesh.tnl \ - --dimensions 1 \ - --size-x ${grid_dim} - - tnl-discrete --mesh mesh.tnl \ - --function ${function} \ - --wave-length 1 \ - --output-file u.tnl - - tnl-discrete --mesh mesh.tnl \ - --function ${function} \ - --wave-length 1 \ - --x-derivative 1 \ - --output-file u-x-exact.tnl - - tnl-discrete --mesh mesh.tnl \ - --function ${function} \ - --wave-length 1 \ - --x-derivative 1 \ - --approximate-derivatives yes \ - --output-file u-x-approx.tnl - - tnl-view --mesh mesh.tnl \ - --check-output-file yes \ - --input-files u*.tnl - cd .. - done - - cd .. -done diff --git a/tests/unit-tests/CMakeLists.txt b/tests/unit-tests/CMakeLists.txt index d21da8ea986a6b649b8e9bb86dc3caba925de739..1cea6d968ea5e7120f4f3fd96bb90d40e7951502 100755 --- a/tests/unit-tests/CMakeLists.txt +++ b/tests/unit-tests/CMakeLists.txt @@ -1,6 +1,7 @@ ADD_SUBDIRECTORY( core ) ADD_SUBDIRECTORY( matrices ) ADD_SUBDIRECTORY( mesh ) +ADD_SUBDIRECTORY( operators ) ADD_SUBDIRECTORY( solver ) set( headers tnlUnitTestStarter.h @@ -51,6 +52,8 @@ ADD_TEST( mesh/tnlGridTest${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnlGrid ADD_TEST( mesh/tnlMeshEntityTest${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnlMeshEntityTest${mpiExt}${debugExt} ) ADD_TEST( mesh/tnlMeshTest${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnlMeshTest${mpiExt}${debugExt} ) +ADD_TEST( operators/diffusion/tnlLinearDiffusionTest${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnlLinearDiffusionTest${mpiExt}${debugExt} ) + if( BUILD_CUDA ) ADD_TEST( core/cuda/tnlCudaTest${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnlCudaTest${mpiExt}${debugExt} ) diff --git a/tests/unit-tests/core/arrays/tnlArrayTester.h b/tests/unit-tests/core/arrays/tnlArrayTester.h index 75c8c82ac31b28edc2e0b0678ab1dfaa82863a2c..e9dedf9999dd0361d7bef7a64cd867baf1f67dbd 100644 --- a/tests/unit-tests/core/arrays/tnlArrayTester.h +++ b/tests/unit-tests/core/arrays/tnlArrayTester.h @@ -42,7 +42,7 @@ class testingClassForArrayTester }; }; -tnlString GetParameterType( const testingClassForArrayTester& c ) +tnlString getType( const testingClassForArrayTester& c ) { return tnlString( "testingClassForArrayTester" ); }; diff --git a/tests/unit-tests/core/arrays/tnlStaticArrayTester.h b/tests/unit-tests/core/arrays/tnlStaticArrayTester.h index 479e7b76e6a3ce3457379627cec36378be7cd577..9a6d4d8a014188b7eed006f73675bd8b1c7ed55b 100644 --- a/tests/unit-tests/core/arrays/tnlStaticArrayTester.h +++ b/tests/unit-tests/core/arrays/tnlStaticArrayTester.h @@ -40,7 +40,7 @@ class testingClassForStaticArrayTester }; }; -tnlString GetParameterType( const testingClassForStaticArrayTester& c ) +tnlString getType( const testingClassForStaticArrayTester& c ) { return tnlString( "testingClassForStaticArrayTester" ); }; diff --git a/tests/unit-tests/core/tnlCUDAKernelsTester.h b/tests/unit-tests/core/tnlCUDAKernelsTester.h index ee01d33b9c7627f1021d4fc4e31f8bfbc96ab940..10e3a6f5e43b26f5c7debfe95ba5860a704ed20a 100644 --- a/tests/unit-tests/core/tnlCUDAKernelsTester.h +++ b/tests/unit-tests/core/tnlCUDAKernelsTester.h @@ -49,32 +49,32 @@ template< class T > class tnlCUDAKernelsTester : public CppUnit :: TestCase CppUnit :: TestResult result; T param; - tnlString test_name = tnlString( "testSimpleReduction1< " ) + GetParameterType( param ) + tnlString( " >" ); + tnlString test_name = tnlString( "testSimpleReduction1< " ) + getType( param ) + tnlString( " >" ); suiteOfTests -> addTest( new CppUnit :: TestCaller< tnlCUDAKernelsTester< T > >( test_name. getString(), & tnlCUDAKernelsTester< T > :: testSimpleReduction1 ) ); - test_name = tnlString( "testSimpleReduction2< " ) + GetParameterType( param ) + tnlString( " >" ); + test_name = tnlString( "testSimpleReduction2< " ) + getType( param ) + tnlString( " >" ); suiteOfTests -> addTest( new CppUnit :: TestCaller< tnlCUDAKernelsTester< T > >( test_name. getString(), & tnlCUDAKernelsTester< T > :: testSimpleReduction2 ) ); - test_name = tnlString( "testSimpleReduction3< " ) + GetParameterType( param ) + tnlString( " >" ); + test_name = tnlString( "testSimpleReduction3< " ) + getType( param ) + tnlString( " >" ); suiteOfTests -> addTest( new CppUnit :: TestCaller< tnlCUDAKernelsTester< T > >( test_name. getString(), & tnlCUDAKernelsTester< T > :: testSimpleReduction3 ) ); - test_name = tnlString( "testSimpleReduction4< " ) + GetParameterType( param ) + tnlString( " >" ); + test_name = tnlString( "testSimpleReduction4< " ) + getType( param ) + tnlString( " >" ); suiteOfTests -> addTest( new CppUnit :: TestCaller< tnlCUDAKernelsTester< T > >( test_name. getString(), & tnlCUDAKernelsTester< T > :: testSimpleReduction4 ) ); - test_name = tnlString( "testSimpleReduction5< " ) + GetParameterType( param ) + tnlString( " >" ); + test_name = tnlString( "testSimpleReduction5< " ) + getType( param ) + tnlString( " >" ); suiteOfTests -> addTest( new CppUnit :: TestCaller< tnlCUDAKernelsTester< T > >( test_name. getString(), & tnlCUDAKernelsTester< T > :: testSimpleReduction5 ) ); - test_name = tnlString( "testReduction< " ) + GetParameterType( param ) + tnlString( " >" ); + test_name = tnlString( "testReduction< " ) + getType( param ) + tnlString( " >" ); suiteOfTests -> addTest( new CppUnit :: TestCaller< tnlCUDAKernelsTester< T > >( test_name. getString(), & tnlCUDAKernelsTester< T > :: testReduction ) @@ -170,8 +170,8 @@ template< class T > class tnlCUDAKernelsTester : public CppUnit :: TestCase cout << "Sum: " << sum << " Seq. sum: " << seq_sum << " !!!!!!!!!!" << endl;*/ T param; - if( GetParameterType( param ) == "float" || - GetParameterType( param ) == "double" ) + if( getType( param ) == "float" || + getType( param ) == "double" ) { if( min != seq_min ) cout << "Diff. min = " << min << " seq. min = " << seq_min; @@ -188,7 +188,7 @@ template< class T > class tnlCUDAKernelsTester : public CppUnit :: TestCase double diff = ( ( double ) sum - ( double ) seq_sum ) / ( double) sum; if( fabs( diff > 1.0e-5 ) ) { - cout << "Diff is " << diff << " for " << GetParameterType( param ) << endl; + cout << "Diff is " << diff << " for " << getType( param ) << endl; abort(); } CPPUNIT_ASSERT( fabs( diff ) < 1.0e-5 ); diff --git a/tests/unit-tests/core/vectors/tnlVectorHostTester.h b/tests/unit-tests/core/vectors/tnlVectorHostTester.h index 3b240a618c2ebe60db700eb99114486e7af605f0..8d73408736ee48d7c5f4f116efc09da845659fe1 100644 --- a/tests/unit-tests/core/vectors/tnlVectorHostTester.h +++ b/tests/unit-tests/core/vectors/tnlVectorHostTester.h @@ -34,7 +34,7 @@ class testingClass }; -tnlString GetParameterType( const testingClass& c ) +tnlString getType( const testingClass& c ) { return tnlString( "testingClass" ); }; diff --git a/tests/unit-tests/operators/CMakeLists.txt b/tests/unit-tests/operators/CMakeLists.txt new file mode 100755 index 0000000000000000000000000000000000000000..14abfb096e414dbf6f49fc4365f59ed6127b3855 --- /dev/null +++ b/tests/unit-tests/operators/CMakeLists.txt @@ -0,0 +1 @@ +ADD_SUBDIRECTORY( diffusion ) diff --git a/tests/unit-tests/operators/diffusion/CMakeLists.txt b/tests/unit-tests/operators/diffusion/CMakeLists.txt new file mode 100755 index 0000000000000000000000000000000000000000..85fef4eaaf8ec59fb0856aceb3d71f7a897bb794 --- /dev/null +++ b/tests/unit-tests/operators/diffusion/CMakeLists.txt @@ -0,0 +1,11 @@ +ADD_EXECUTABLE( tnlLinearDiffusionTest${mpiExt}${debugExt} tnlLinearDiffusionTest.cpp ) +TARGET_LINK_LIBRARIES( tnlLinearDiffusionTest${mpiExt}${debugExt} ${CPPUNIT_LIBRARIES} + tnl${mpiExt}${debugExt}-0.1 ) + +if( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE( tnlLinearDiffusionTest-cuda${mpiExt}${debugExt} ${headers} tnlLinearDiffusionTest.cu + OPTIONS ${CUDA_ADD_EXECUTABLE_OPTIONS} ) + TARGET_LINK_LIBRARIES( tnlLinearDiffusionTest-cuda${mpiExt}${debugExt} ${CPPUNIT_LIBRARIES} + tnl${mpiExt}${debugExt}-0.1 ) +endif() + diff --git a/tests/unit-tests/operators/diffusion/tnlLinearDiffusionTest.cpp b/tests/unit-tests/operators/diffusion/tnlLinearDiffusionTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..525725954cd2e34eeb5d2b954f06e482b9ac0bd2 --- /dev/null +++ b/tests/unit-tests/operators/diffusion/tnlLinearDiffusionTest.cpp @@ -0,0 +1,77 @@ +/*************************************************************************** + tnlLinearDiffusionTest.cpp - description + ------------------- + begin : Sep 4, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <tnlConfig.h> +#include <core/tnlHost.h> +#include <cstdlib> + +#include "../tnlPDEOperatorEocTester.h" +#include "../../tnlUnitTestStarter.h" +#include <mesh/tnlGrid.h> +#include <operators/diffusion/tnlLinearDiffusion.h> +#include <operators/diffusion/tnlExactLinearDiffusion.h> +#include "../tnlPDEOperatorEocTestResult.h" +#include <functions/tnlExpBumpFunction.h> + +template< int Dimensions, + typename Real, + typename Device, + typename Index, + typename TestFunction > +class tnlPDEOperatorEocTestResult< tnlLinearDiffusion< tnlGrid< Dimensions, Real, Device, Index >, Real, Index >, + TestFunction > +{ + public: + static Real getL1Eoc() { return ( Real ) 2.0; }; + static Real getL1Tolerance() { return ( Real ) 0.05; }; + + static Real getL2Eoc() { return ( Real ) 2.0; }; + static Real getL2Tolerance() { return ( Real ) 0.05; }; + + static Real getMaxEoc() { return ( Real ) 2.0; }; + static Real getMaxTolerance() { return ( Real ) 0.05; }; + +}; + +int main( int argc, char* argv[] ) +{ + const bool verbose( true ); + const int MeshSize( 32 ); +#ifdef HAVE_CPPUNIT + if( ! tnlUnitTestStarter :: run< tnlPDEOperatorEocTester< tnlLinearDiffusion< tnlGrid< 1, double, tnlHost, int >, double, int >, + tnlExactLinearDiffusion< 1 >, + tnlExpBumpFunction< 1, double >, + MeshSize, + verbose > >() || + ! tnlUnitTestStarter :: run< tnlPDEOperatorEocTester< tnlLinearDiffusion< tnlGrid< 2, double, tnlHost, int >, double, int >, + tnlExactLinearDiffusion< 2 >, + tnlExpBumpFunction< 2, double >, + MeshSize, + verbose > >() || + ! tnlUnitTestStarter :: run< tnlPDEOperatorEocTester< tnlLinearDiffusion< tnlGrid< 3, double, tnlHost, int >, double, int >, + tnlExactLinearDiffusion< 3 >, + tnlExpBumpFunction< 3, double >, + MeshSize, + verbose > >() + ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +#else + return EXIT_FAILURE; +#endif +} + diff --git a/tests/unit-tests/operators/tnlPDEOperatorEocTestResult.h b/tests/unit-tests/operators/tnlPDEOperatorEocTestResult.h new file mode 100644 index 0000000000000000000000000000000000000000..0214a086e02688b8a017cfd2b897c76a4cd0d817 --- /dev/null +++ b/tests/unit-tests/operators/tnlPDEOperatorEocTestResult.h @@ -0,0 +1,28 @@ +/*************************************************************************** + tnlPDEOperatorEocTestResult.h - description + ------------------- + begin : Sep 5, 2014 + copyright : (C) 2014 by oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TNLPDEOPERATOREOCTESTRESULT_H_ +#define TNLPDEOPERATOREOCTESTRESULT_H_ + +template< typename ApproximateOperator, + typename TestFunction > +class tnlPDEOperatorEocTestResult +{ +}; + + +#endif /* TNLPDEOPERATOREOCTESTRESULT_H_ */ diff --git a/tests/unit-tests/operators/tnlPDEOperatorEocTestSetter.h b/tests/unit-tests/operators/tnlPDEOperatorEocTestSetter.h new file mode 100644 index 0000000000000000000000000000000000000000..2ed0ce0a0e7db203cc0ed19120af293d38a972f1 --- /dev/null +++ b/tests/unit-tests/operators/tnlPDEOperatorEocTestSetter.h @@ -0,0 +1,163 @@ +/*************************************************************************** + tnlPDEOperatorEocTestSetter.h - description + ------------------- + begin : Sep 4, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TNLPDEOPERATOREOCTESTSETTER_H_ +#define TNLPDEOPERATOREOCTESTSETTER_H_ + +#include <mesh/tnlGrid.h> +#include <functions/tnlExpBumpFunction.h> + +template< typename ApproximateOperator, + typename ExactOperator, + typename Mesh, + typename TestFunction > +class tnlPDEOperatorEocTestSetter +{ +}; + +template< typename ApproximateOperator, + typename ExactOperator, + typename Real, + typename Device, + typename Index > +class tnlPDEOperatorEocTestSetter< ApproximateOperator, + ExactOperator, + tnlGrid< 1, Real, Device, Index >, + tnlExpBumpFunction< 1, Real > > +{ + public: + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + typedef tnlGrid< 1, Real, Device, Index > MeshType; + typedef ExactOperator ExactOperatorType; + typedef ApproximateOperator ApproximateOperatorType; + typedef typename MeshType::VertexType VertexType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef tnlExpBumpFunction< 1, Real > FunctionType; + + static void setMesh( MeshType& mesh, + const IndexType& size ) + { + VertexType origin, proportions; + origin.x() = -1.0; + proportions.x() = 2.0; + mesh.setDomain( origin, proportions ); + + CoordinatesType dimensions; + dimensions.x() = size; + mesh.setDimensions( dimensions ); + }; + + static void setFunction( FunctionType& function ) + { + function.setAmplitude( 1.0 ); + function.setSigma( 0.5 ); + }; +}; + +template< typename ApproximateOperator, + typename ExactOperator, + typename Real, + typename Device, + typename Index > +class tnlPDEOperatorEocTestSetter< ApproximateOperator, + ExactOperator, + tnlGrid< 2, Real, Device, Index >, + tnlExpBumpFunction< 2, Real > > +{ + public: + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + typedef tnlGrid< 2, Real, Device, Index > MeshType; + typedef ExactOperator ExactOperatorType; + typedef ApproximateOperator ApproximateOperatorType; + typedef typename MeshType::VertexType VertexType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef tnlExpBumpFunction< 2, Real > FunctionType; + + static void setMesh( MeshType& mesh, + const IndexType& size ) + { + VertexType origin, proportions; + origin.x() = -1.0; + origin.y() = -1.0; + proportions.x() = 2.0; + proportions.y() = 2.0; + mesh.setDomain( origin, proportions ); + + CoordinatesType dimensions; + dimensions.x() = size; + dimensions.y() = size; + mesh.setDimensions( dimensions ); + }; + + static void setFunction( FunctionType& function ) + { + function.setAmplitude( 1.0 ); + function.setSigma( 0.5 ); + }; +}; + +template< typename ApproximateOperator, + typename ExactOperator, + typename Real, + typename Device, + typename Index > +class tnlPDEOperatorEocTestSetter< ApproximateOperator, + ExactOperator, + tnlGrid< 3, Real, Device, Index >, + tnlExpBumpFunction< 3, Real > > +{ + public: + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + typedef tnlGrid< 3, Real, Device, Index > MeshType; + typedef ExactOperator ExactOperatorType; + typedef ApproximateOperator ApproximateOperatorType; + typedef typename MeshType::VertexType VertexType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef tnlExpBumpFunction< 3, Real > FunctionType; + + static void setMesh( MeshType& mesh, + const IndexType& size ) + { + VertexType origin, proportions; + origin.x() = -1.0; + origin.y() = -1.0; + origin.z() = -1.0; + proportions.x() = 2.0; + proportions.y() = 2.0; + proportions.z() = 2.0; + mesh.setDomain( origin, proportions ); + + CoordinatesType dimensions; + dimensions.x() = size; + dimensions.y() = size; + dimensions.z() = size; + mesh.setDimensions( dimensions ); + }; + + static void setFunction( FunctionType& function ) + { + function.setAmplitude( 1.0 ); + function.setSigma( 0.5 ); + }; +}; +#endif /* TNLPDEOPERATOREOCTESTSETTER_H_ */ diff --git a/tests/unit-tests/operators/tnlPDEOperatorEocTester.h b/tests/unit-tests/operators/tnlPDEOperatorEocTester.h new file mode 100644 index 0000000000000000000000000000000000000000..9e1b50ff541a6976ee1724025aca600d5b70344b --- /dev/null +++ b/tests/unit-tests/operators/tnlPDEOperatorEocTester.h @@ -0,0 +1,119 @@ +/*************************************************************************** + tnlPDEOperatorEocTester.h - description + ------------------- + begin : Aug 30, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TNLPDEOPERATOREOCTESTER_H_ +#define TNLPDEOPERATOREOCTESTER_H_ + +#ifdef HAVE_CPPUNIT +#include <cppunit/TestSuite.h> +#include <cppunit/TestResult.h> +#include <cppunit/TestCaller.h> +#include <cppunit/TestCase.h> +#include <cppunit/Message.h> +#include <unit-tests/tnlApproximationError.h> +#include <unit-tests/operators/tnlPDEOperatorEocTestSetter.h> +#include <unit-tests/operators/tnlPDEOperatorEocTestResult.h> + +template< typename ApproximateOperator, + typename ExactOperator, + typename TestFunction, + int MeshSize, + bool verbose = false > +class tnlPDEOperatorEocTester : public CppUnit :: TestCase +{ + public: + typedef tnlPDEOperatorEocTester< ApproximateOperator, ExactOperator, TestFunction, MeshSize, verbose > TesterType; + typedef typename CppUnit::TestCaller< TesterType > TestCallerType; + typedef typename ApproximateOperator::MeshType MeshType; + typedef typename ApproximateOperator::RealType RealType; + typedef typename ApproximateOperator::IndexType IndexType; + typedef tnlPDEOperatorEocTestSetter< ApproximateOperator, ExactOperator, MeshType, TestFunction > TestSetter; + typedef tnlPDEOperatorEocTestResult< ApproximateOperator, TestFunction > TestResult; + + tnlPDEOperatorEocTester(){}; + + virtual + ~tnlPDEOperatorEocTester(){}; + + static CppUnit :: Test* suite() + { + tnlString testName = tnlString( "tnlPDEOperatorEocTester< " ) + + ApproximateOperator::getType() + ", " + + ExactOperator::getType() + ", " + + TestFunction::getType() + ", " + + tnlString( MeshSize ) + ", " + + tnlString( verbose ) + " >"; + CppUnit :: TestSuite* suiteOfTests = new CppUnit :: TestSuite( testName.getString() ); + CppUnit :: TestResult result; + + suiteOfTests -> addTest( new TestCallerType( "approximationTest", &TesterType::approximationTest ) ); + + return suiteOfTests; + } + + void approximationTest() + { + TestFunction testFunction; + TestSetter::setFunction( testFunction ); + + MeshType mesh; + + ExactOperator exactOperator; + ApproximateOperator approximateOperator; + + TestSetter::setMesh( mesh, MeshSize ); + RealType coarseL1Err, coarseL2Err, coarseMaxErr; + tnlApproximationError< MeshType, + ExactOperator, + ApproximateOperator, + TestFunction > + ::getError( mesh, + exactOperator, + approximateOperator, + testFunction, + coarseL1Err, + coarseL2Err, + coarseMaxErr ); + + TestSetter::setMesh( mesh, 2*MeshSize ); + RealType fineL1Err, fineL2Err, fineMaxErr; + tnlApproximationError< MeshType, + ExactOperator, + ApproximateOperator, + TestFunction > + ::getError( mesh, + exactOperator, + approximateOperator, + testFunction, + fineL1Err, + fineL2Err, + fineMaxErr ); + RealType l1Eoc = log( coarseL1Err / fineL1Err) / log( 2.0 ); + RealType l2Eoc = log( coarseL2Err / fineL2Err) / log( 2.0 ); + RealType maxEoc = log( coarseMaxErr / fineMaxErr) / log( 2.0 ); + + if( verbose ) + cerr << "L1Eoc = " << l1Eoc << " L2Eoc = " << l2Eoc << " maxEoc = " << maxEoc << endl; + + CPPUNIT_ASSERT( fabs( l1Eoc - TestResult::getL1Eoc() ) < TestResult::getL1Tolerance() ); + CPPUNIT_ASSERT( fabs( l2Eoc - TestResult::getL2Eoc() ) < TestResult::getL2Tolerance() ); + CPPUNIT_ASSERT( fabs( maxEoc - TestResult::getMaxEoc() ) < TestResult::getMaxTolerance() ); + } +}; + +#endif /* HAVE_CPPUNIT */ +#endif /* TNLPDEOPERATOREOCTESTER_H_ */ diff --git a/tests/unit-tests/solver/tnlMersonSolverTester.h b/tests/unit-tests/solver/tnlMersonSolverTester.h index f27c966d6ade929e2a81585ec4e22cd5af943ce6..726f270a512c3e06e2ad29895032238485c6451c 100644 --- a/tests/unit-tests/solver/tnlMersonSolverTester.h +++ b/tests/unit-tests/solver/tnlMersonSolverTester.h @@ -83,11 +83,11 @@ class tnlMersonSolverTester : public CppUnit :: TestCase tnlString getType() const { return tnlString( "tnlMersonSolverTester< " ) + - GetParameterType( Real( 0 ) ) + + getType( Real( 0 ) ) + tnlString( ", ") + Device :: getDeviceType() + tnlString( ", ") + - GetParameterType( Index( 0 ) ) + + getType( Index( 0 ) ) + tnlString( " >" ); }; @@ -97,7 +97,7 @@ class tnlMersonSolverTester : public CppUnit :: TestCase CppUnit :: TestResult result; Real param; - tnlString test_name = tnlString( "testUpdateU< " ) + GetParameterType( param ) + tnlString( " >" ); + tnlString test_name = tnlString( "testUpdateU< " ) + getType( param ) + tnlString( " >" ); suiteOfTests -> addTest( new CppUnit :: TestCaller< tnlMersonSolverTester< Real, Device, Index > >( test_name. getString(), & tnlMersonSolverTester< Real, Device, Index > :: testUpdateU ) diff --git a/tests/unit-tests/tnlApproximationError.h b/tests/unit-tests/tnlApproximationError.h new file mode 100644 index 0000000000000000000000000000000000000000..63d44de327aa6a766881f32c489c1ffc775a11bc --- /dev/null +++ b/tests/unit-tests/tnlApproximationError.h @@ -0,0 +1,47 @@ +/*************************************************************************** + tnlApproximationError.h - description + ------------------- + begin : Aug 7, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TNLAPPROXIMATIONERROR_H_ +#define TNLAPPROXIMATIONERROR_H_ + +template< typename Mesh, + typename ExactOperator, + typename ApproximateOperator, + typename Function > +class tnlApproximationError +{ + public: + + typedef typename ApproximateOperator::RealType RealType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef typename MeshType::VertexType VertexType; + + static void getError( const Mesh& mesh, + const ExactOperator& exactOperator, + const ApproximateOperator& approximateOperator, + const Function& function, + RealType& l1Err, + RealType& l2Err, + RealType& maxErr ); +}; + +#include "tnlApproximationError_impl.h" + +#endif /* TNLAPPROXIMATIONERROR_H_ */ diff --git a/tests/unit-tests/tnlApproximationError_impl.h b/tests/unit-tests/tnlApproximationError_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..e1082644951e7c6240845a36b76d585c058880d5 --- /dev/null +++ b/tests/unit-tests/tnlApproximationError_impl.h @@ -0,0 +1,72 @@ +/*************************************************************************** + tnlApproximationError_impl.h - description + ------------------- + begin : Aug 8, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TNLAPPROXIMATIONERROR_IMPL_H_ +#define TNLAPPROXIMATIONERROR_IMPL_H_ + +#include <mesh/tnlTraversal.h> +#include <core/vectors/tnlVector.h> +#include <functions/tnlFunctionDiscretizer.h> + +template< typename Mesh, + typename ExactOperator, + typename ApproximateOperator, + typename Function > +void +tnlApproximationError< Mesh, ExactOperator, ApproximateOperator, Function >:: +getError( const Mesh& mesh, + const ExactOperator& exactOperator, + const ApproximateOperator& approximateOperator, + const Function& function, + RealType& l1Err, + RealType& l2Err, + RealType& maxErr ) +{ + typedef tnlVector< RealType, DeviceType, IndexType > Vector; + Vector functionData, exactData, approximateData; + const IndexType entities = mesh.getNumberOfCells(); + + if( ! functionData.setSize( entities ) || + ! exactData.setSize( entities ) || + ! approximateData.setSize( entities ) ) + return; + + tnlFunctionDiscretizer< Mesh, Function, Vector >::template discretize< 0, 0, 0 >( mesh, function, functionData ); + + if( DeviceType::DeviceType == ( int ) tnlHostDevice ) + { + for( IndexType i = 0; i < entities; i++ ) + { + if( ! mesh.isBoundaryCell( i ) ) + { + VertexType v = mesh.getCellCenter( i ); + exactData[ i ] = exactOperator.getValue( function, v ); + approximateData[ i ] = approximateOperator.getValue( mesh, i, functionData ); + } + else exactData[ i ] = approximateData[ i ]; + } + } + if( DeviceType::DeviceType == ( int ) tnlCudaDevice ) + { + // TODO + } + l1Err = mesh.getDifferenceLpNorm( exactData, approximateData, ( RealType ) 1.0 ); + l2Err = mesh.getDifferenceLpNorm( exactData, approximateData, ( RealType ) 2.0 ); + maxErr = mesh.getDifferenceAbsMax( exactData, approximateData ); +} + +#endif /* TNLAPPROXIMATIONERROR_IMPL_H_ */ diff --git a/tools/src/tnl-init.h b/tools/src/tnl-init.h index 4d9ff48798d5ec3c8f2e83e3634cca02e9e1f5c9..1be06eaa73d046e2ed9173b35ac3ec9dd32b2338 100644 --- a/tools/src/tnl-init.h +++ b/tools/src/tnl-init.h @@ -25,7 +25,7 @@ #include <functions/tnlSinWaveFunction.h> #include <functions/tnlSinBumpsFunction.h> #include <functions/tnlExpBumpFunction.h> -#include <schemes/tnlFiniteDifferences.h> +#include <operators/tnlFiniteDifferences.h> template< typename MeshType, typename FunctionType, @@ -41,7 +41,7 @@ bool renderFunction( const tnlParameterContainer& parameters ) return false; FunctionType function; - if( ! function.init( parameters ) ) + if( ! function.init( parameters, "" ) ) return false; typedef tnlVector< typename MeshType::RealType, tnlHost, typename MeshType::IndexType > DiscreteFunctionType; DiscreteFunctionType discreteFunction; @@ -166,12 +166,12 @@ bool resolveFunction( const tnlParameterContainer& parameters ) cout << "+ -> Generating function " << functionName << " ... " << endl; if( functionName == "sin-wave" ) { - typedef tnlSinWaveFunction< MeshType::Dimensions, typename MeshType::VertexType, typename MeshType::DeviceType > FunctionType; + typedef tnlSinWaveFunction< MeshType::Dimensions, typename MeshType::RealType > FunctionType; return resolveDerivatives< MeshType, FunctionType >( parameters ); } if( functionName == "sin-bumps" ) { - typedef tnlSinBumpsFunction< MeshType::Dimensions, typename MeshType::VertexType, typename MeshType::DeviceType > FunctionType; + typedef tnlSinBumpsFunction< MeshType::Dimensions, typename MeshType::RealType > FunctionType; return resolveDerivatives< MeshType, FunctionType >( parameters ); } if( functionName == "exp-bump" )